ProtoView WinX Version 3

ProtoView TreeViewX

Version 3.0

ProtoView Development Corporation

Information in this document is subject to change without notice and does not represent a commitment on the part of ProtoView Development Corporation. The software described in this document is furnished under the provisions of a license agreement. The purchaser, and only the purchaser, may make one copy of the development software for backup purposes. No part of this manual may be reproduced or transmitted in any form or by any means, electronic or mechanical, including but not limited to photocopying and recording, for any purpose without the written consent of ProtoView Development Corporation.

ProtoView Development Corporation
2540 Route 130
Cranbury, New Jersey 08512
http://www.protoview.com

Ó Copyright ProtoView Development Corporation, 1995-98. All rights reserved.


TreeViewX Introduction

License Agreement

This is a legal agreement between you, the end user, and ProtoView Development Corporation. By opening this envelope you are agreeing to accept ownership of this product and to be bound by the terms of this agreement. It also contains proprietary source code which you are entitled to use only under the terms of this license agreement. If, after reading this agreement, you do not agree with its terms, return the software and packaging within thirty days of purchase to the party from whom you received it for a refund. In order to receive a refund, the software must be in resellable condition. IF YOU PURCHASE THE SOURCE THE SALE IS FINAL.

ProtoView Software License For TreeViewX
1. Grant of License. ProtoView Development Corp. grants a limited, non-exclusive license to use one copy of the application development tool called TreeViewX Component Library for the purpose of developing applications for the Windows environment. This copy of ProtoView must exist on a single terminal connected to a single computer (i.e., with a single CPU). You may not network TreeViewX or otherwise use it for development on more than one computer at the same time.

2. Runtime Distribution License. ProtoView Development Corp. grants you a royalty-free right to distribute copies of the runtime dynamic link libraries for use with applications you have developed using TreeViewX. TreeViewX runtime files are listed in exhibit A. These libraries may not be distributed for any other purpose than to accompany software that you have developed using TreeViewX. You may use TreeViewX in your specific purpose application programs, in which case ProtoView grants you permission under ProtoView's copyright to use, give away or sell such programs without additional licenses or fees, as long as all copies of these programs bear a valid copyright notice and provided that your program is not merely a set or subset of TreeViewX or a compilation or development tool or library which includes all or a portion of TreeViewX, or is otherwise a product that is generally competitive with or a substitute for TreeViewX. This permission is granted solely for the purpose set forth above, and you are not authorized to use TreeViewX in any other manner.

3. Copyright. TreeViewX is owned by ProtoView Development Corporation and is protected by United States copyright laws and international treaty provisions. You may make one copy of the software for backup purposes. You may not, under any circumstances, copy the manual and other written materials that accompany this software.

4. Other Restrictions. You may not rent or lease TreeViewX software, but you may transfer the software and accompanying written materials on a permanent basis provided you retain no copies and the recipient agrees to the terms of this Agreement. You may not reverse engineer, decompile, or disassemble this software.

Limited Warranty
ProtoView Development Corp. warrants that the software herein will perform substantially in accordance with the accompanying written materials for a period of thirty days from the date of receipt. Any implied warranties on ProtoView are limited to ninety days. Some states do not allow limitations on duration of an implied warranty, so the above limitation may not apply to you.
Customer Remedies. ProtoView's entire liability and your exclusive remedy shall be, at ProtoView's option, either (a) return of the price paid or (b) replacement of the software that does not meet ProtoView's Limited Warranty and which is returned to ProtoView with a copy of your receipt. This Limited Warranty is void if failure of the software has resulted from accident, abuse, or misapplication. Any replacement of the software will be warranted for the remainder of the original warranty period or 30 days, whichever is longer.

NO OTHER WARRANTIES. PROTOVIEW DEVELOPMENT DISCLAIMS ALL OTHER WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, WITH RESPECT TO THE SOFTWARE AND THE ACCOMPANYING WRITTEN MATERIALS. THIS LIMITED WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS. YOU MAY HAVE OTHERS, WHICH VARY FROM STATE TO STATE.
NO LIABILITY FOR CONSEQUENTIAL DAMAGES. IN NO EVENT SHALL PROTOVIEW OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE THIS PROTVIEW PRODUCT, EVEN IF PROTOVIEW HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE LIMITATION MAY NOT APPLY TO YOU.

Exhibit A

pvtreex.ocx
pvtreex.cab

What is TreeViewX?

TreeViewX is a powerful control for displaying data with parent/child relationships. Like the treeview which is part of the Windows operating system, items in the TreeView can have children, and can either be open (display its children) or closed (hide its children). Unlike the treeview which is part of the Windows OS, the TreeViewX supports multiple selection, multi-column display, and can be populated by a data source.

Upgrading to TreeViewX 3.0

TreeViewX is a new control with a new GUID - it has no peer in the WinX 2.1 or ActiveX Component Suite 2.1 libraries. If you wish to upgrade from the TreeView included with WinX 2.1 or ACS 2.1, please follow these directions.

To upgrade to TreeViewX, you will need to replace any TreeViews you have with the newer TreeViewX v3.0. Since these controls have separate and unique GUIDs, you will be able to continue your current development with v2.1 on the same desktop or client machines you will be working with TreeViewX v3.0.

  1. Open your existing application.
  2. Load TreeViewX v3.0 onto your toolbox.
  3. Delete the original instance of TreeView.
  4. Create a new instance of TreeViewX on the same form as the original TreeView. Place it in the exact position as the original tree component.
  5. Change the name of the new tree to match the name of the original tree.
  6. Reset properties for TreeViewX to match those of the original TreeView.
  7. Repeat steps 3 – 6 for each treeview in your application. Note that since TreeViewX 3.0 and 2.x have separate and unique GUIDs, there is no need to replace all your treeviews at once. You can have a project that contains both versions of the TreeViewX at the same time!

If you explicitely declare any Branch objects in code, you will need to change these references to PVBranch objects.

Data Binding with TreeViewX

The TreeViewX control is a complex bound control, like a grid control. It has a DataSource property which is bound. However, the TreeViewX does not display all columns in the data source. The property DataField determines which column in the data source will be read and displayed for each level. For each item read from the database, the events BeforeDBAddNode and AfterDBAddNode are fired, allowing you to customize the items or add sub nodes. Please see the notes specifically for TreeViewX Data Binding for a description of this process.

TreeViewX File Listing

TreeViewX will install different components based on the install you purchased and options you select during the install process. Certain components will not be installed if you do not select those options during the installation.
A TreeViewX ActiveX setup may install the following components:

1. The TreeViewX ActiveX Control (.OCX)

pvtreex.ocx

2. Cabinet Files (Release Install Only)

pvtreex.cab

3. Help Files

4. Sample Files


ProtoView Product Support

Product Support

Have a question regarding this product? ProtoView offers a variety of resources to answer your question and get you on your way to being more productive. Please read below to find out the best way to leverage that support.

Frequently Asked Questions

ProtoView has compiled a list of some of the most frequently asked questions in our On-Line FAQ area of the ProtoView web site at http://www.protoview.com/faqs. This area is maintained and updated on a regular basis so make this your first stop for getting your questions answered.

Online Sample Area

In addition to the samples included with this product, ProtoView has placed additional samples in the "online sample area" of the ProtoView web site at http://www.protoview.com/samples. This area is maintained and updated on a regular basis and features ProtoView products integrating with the latest application technology.

Demos

If you are using an evaluation copy of this product and have questions regarding its use, ProtoView technical and service staff can be reached at:

demo@protoview.com

Technical Support

If you own a copy of this product and have questions about this product, ProtoView offers different types of technical support services (such as Priority and Premier support packages) for you to choose from. Please contact ProtoView for a list of support options to fit your needs.

When contacting Technical Support, please place your Customer ID in the subject line of all correspondence (both e-mail and fax). By using this ID, you will not only help us verify you as a customer, but it will also help to expedite your request. If you do not know your Customer ID, send a message to info@protoview.com. Include your name, company name, address, phone number, fax number and e-mail address in the body of the message. Failure to use your Customer ID can result in a refusal of service, so please take a few moments to gather that information.

ProtoView technical services is provided Monday through Friday 9:00 am - 5:00 pm EST (excluding holidays). ProtoView can be contacted through the following channels:

Phone:

609-655-5000

Fax:

609-655-5353

Internet:

tech@protoview.com

http://www.protoview.com /support

Subscription Services

Always want to be sure you are using the latest version of your ProtoView products? Join our subscription service and receive a copy your ProtoView products whenever they are updated for an entire year for free. This includes major upgrades which normally require a fee to upgrade, so this value is unbeatable! Contact ProtoView at 800-231-8588 (609-655-5000 for international customers) or info@protoview.com to find out more information on our subscription services.

Professional Services

ProtoView has a core team of specialists available to build your end-to-end business solutions. Contact ProtoView at 800-231-8588 (609-655-5000 for international customers) or info@protoview.com to find out more information on how to make this team work for you.


TreeViewX Tutorials

Tutorials

For these tutorials, all information will be given regarding Visual Studio 6. The run-time code should be backward compatible with Visual Basic 5 (except for hierarchical binding). For hierarchical data-binding, you need to be using Visual Studio 6.x, or at least the Data Access SDK 2.0 which installs the ADO Data Control (ADC DC) and the MDAC components. Currently Visual Basic 5.0 does not have support for design-time data binding with ADO Data-Bound controls. If you wish to bind to TreeViewX 3.0, you will need to do this at run-time.

Visual Basic

The following Visual Basic tutorials are offered:

  • Binding using ADO DC at Design-Time, Non-Hierarchical
  • Binding using ADO DC at Run-Time, Non-Hierarchical
  • Binding using DataView at Design-Time, Hierarchical
  • Binding using DataView at Run-Time, Hierarchical

Binding using ADO DC at Design-Time, Non-Hierarchical

  1. Start VB 6
  2. Create a new "Standard EXE" project
  3. Add the ADO DC and TreeViewX to your Project and place them on your form.
  4. Right-click on the ADO DC and select "Properties"
  5. On the "General" Property page, select "Use ODBC Data Source Name"
  6. Select your "Jet NorthWind connection" -- You may need to set this up through the ODBC 32-bit Administrator through your Control Panel beforehand (or select New)
  7. On the "RecordSource" Property page, select "adCmdTable" from the "Command Type" combobox
  8. Select the "Customers" table from the "Table or Stored Procedure Name" combobox
  9. Click OK
  10. Select TreeViewX on the form
  11. In the "Standard Properties Window" in VB, change the DataSource property to the ADO DC
  12. Right-click on TreeViewX and select "Properties..."
  13. On the Data-Binding Property Page, double-click on "CompanyName" in the Available Columns list.
  14. Click on OK to close the Property Pages
  15. Run your application.

Binding using ADO DC at Run-Time, Non-Hierarchical

This only shows a basic table. For a hierarchical view, please refer to the sample in VC 6 using the ADO DC.

  1. Start VB 6
  2. Create a new "Standard EXE" project
  3. Add the ADO DC and TreeViewX to your Project and place them on your form.
  4. Right-click on the ADO DC and select "Properties"
  5. On the "General" Property page, select "Use ODBC Data Source Name"
  6. Select your "Jet NorthWind connection" -- You may need to set this up through the ODBC 32-bit Administrator through your Control Panel beforehand (or select New)
  7. On the "RecordSource" Property page, select "adCmdTable" from the "Command Type" combobox
  8. Select the "Customers" table from the "Table or Stored Procedure Name" combobox
  9. Click OK
  10. Double click on the background of the form to edit the code for the Form Load sub
  11. Add the following lines of code:

    PVTreeViewX1.DataField(0) = "CompanyName"
    PVTreeViewX1.DataSource = Adodc1
  12. Run your application

Note: Before attempting to bind TreeView hierarchically, please be sure that you understand the purpose of the DataField property and how to use it.

One of the new features of Visual Basic 6.0 is the DataView which allows you to easily set up a hierarchical recordset at design-time. Here&rsquo;s how to use hierarchical recordsets with TreeViewX:

Binding using DataView at Design-Time, Hierarchical

Here, we will show how to bind three levels deep.

  1. Start VB 6
  2. Create a new "Standard EXE" project
  3. Add TreeViewX to your Project and place it on your form
  4. On the Toolbar in VB 6, you should have an icon for the DataView Window which looks like:
    , click on it. This will bring up the DataView Window.
  5. On the DataView Window, click on the second toolbar button, "Add a Data Environment to the Current Project". Click on it...
  6. In the DataEnvironment Window, click on Connection1, and in the Standard Properties Window, change the "(Name)" field from "Connection1" to "NWind"
  7. Back in the DataEnvironment Window, Connection1 should now be NWind. Right-click on it, and select "Properties..."
  8. Select "Microsoft OLE DB Provider for ODBC Drivers", and click on Next
  9. Select your NorthWind Jet DataBase under the Data Source Name combobox. You may need to set this up through your 32-bit ODBC Administrator in your Control Panel.
  10. Click on "Test Connection". You should get message box that says "Test connection succeeded"
  11. Click on OK, click on OK.
  12. In the DataView Window, NWind should now be listed under "Data Environment Connections" with a plus sign. Click on the plus sign to expand it.
  13. Click on the plus sign next to "Tables" to expand it
  14. Drag "Customers" from the DataView Window to the DataEnvironment Window.
  15. Repeat step 14 for "Orders" and "Order Details"
  16. In the DataEnvironment Window, right-click on Orders, and select "Properties..."
  17. Click on the Relation tab, and check "Relate to a Parent Command Object"
  18. In the Parent Command combobox, select "Customers"
  19. In the Relation Definition section on that property page, you should now have CustomerID in both comboboxes, if so click on Add. If not, select CustomerID in both comboboxes then click on Add
  20. Click on OK
  21. Right-click on "Order_Details" in the DataEnvironment Window and select "Properties..."
  22. Click on the Relation tab, and check "Relate to a Parent Command Object"
  23. In the Parent Command combobox, select "Orders"
  24. In the Relation Definition section on that property page, you should now have OrderID in both comboboxes, if so click on Add. If not, select OrderID in both comboboxes then click on Add
  25. Click OK
  26. Close the DataView Window
  27. Your DataEnvironment Window should now contain a hierarchical representation of three tables from the NorthWind Database. Close the DataEnvironment Window
  28. Select TreeViewX on the form.
  29. In the Standard Properties Window in VB, change the DataSource property to "DataEnvironment1"
  30. Change the DataMember property to "Customers"
  31. Right-click on TreeViewX and select "Properties"
  32. On the Data-Binding Property page, expand "Customers", scroll down and expand "Orders", scroll down and expand "Order_Details"
  33. Scroll back up and double-click on "CompanyName" which should be a child of "Customers".
  34. Scroll down and double-click on "OrderID" which should be a child of "Orders"
  35. Scroll down and double-click on "ProductID" which should be a child of "Order_Details"
  36. Click on OK to close the Property Pages
  37. Run your project

When you run your project, you will get a list of company names. Under each company is all the orders associated with that company. Under each Order is all the products for that order.

Binding using DataView at Run-Time, Hierarchical

  1. Start VB 6
  2. Create a new "Standard EXE" project
  3. Add TreeViewX to your Project and place it on your form
  4. On the Toolbar in VB 6, you should have an icon for the DataView Window which looks like:
    , click on it. This will bring up the DataView Window.
  5. On the DataView Window, click on the second toolbar button, "Add a Data Environment to the Current Project". Click on it...
  6. In the DataEnvironment Window, click on Connection1, and in the Standard Properties Window, change the "(Name)" field from "Connection1" to "NWind"
  7. Back in the DataEnvironment Window, Connection1 should now be NWind. Right-click on it, and select "Properties..."
  8. Select "Microsoft OLE DB Provider for ODBC Drivers", and click on Next
  9. Select your NorthWind Jet DataBase under the Data Source Name combobox. You may need to set this up through your 32-bit ODBC Administrator in your Control Panel.
  10. Click on "Test Connection". You should get message box that says "Test connection succeeded"
  11. Click on OK, click on OK.
  12. In the DataView Window, NWind should now be listed under "Data Environment Connections" with a plus sign. Click on the plus sign to expand it.
  13. Click on the plus sign next to "Tables" to expand it
  14. Drag "Customers" from the DataView Window to the DataEnvironment Window.
  15. Repeat step 14 for "Orders" and "Order Details"
  16. In the DataEnvironment Window, right-click on Orders, and select "Properties..."
  17. Click on the Relation tab, and check "Relate to a Parent Command Object"
  18. In the Parent Command combobox, select "Customers"
  19. In the Relation Definition section on that property page, you should now have CustomerID in both comboboxes, if so click on Add. If not, select CustomerID in both comboboxes then click on Add
  20. Click on OK
  21. Right-click on "Order_Details" in the DataEnvironment Window and select "Properties..."
  22. Click on the Relation tab, and check "Relate to a Parent Command Object"
  23. In the Parent Command combobox, select "Orders"
  24. In the Relation Definition section on that property page, you should now have OrderID in both comboboxes, if so click on Add. If not, select OrderID in both comboboxes then click on Add
  25. Click OK
  26. Close the DataView Window
  27. Your DataEnvironment Window should now contain a hierarchical representation of three tables from the NorthWind Database. Close the DataEnvironment Window
  28. Add the following code to the Form Load:

    PVTreeViewX1.DataField(0) = "Customers.CompanyName"
    PVTreeViewX1.DataField(1) = "Orders.OrderID"
    PVTreeViewX1.DataField(2) = "Order_Details.ProductID"
    PVTreeViewX1.DataMember = "Customers"
    PVTreeViewX1.DataSource = DataEnvironment1
  29. Run your project

NOTE: When binding to a single level, you only need to specify the Field Name in DataField(0). If you are binding to multiple level as this example shows, you need to specify the [Table Name].[Field Name] as shown.

The DataMember property specifies which level TreeViewX should begin access to. If, for instance, you don&rsquo;t want to see the Customer&rsquo;s information, just Orders and Order Details, then specify the DataMember to be "Orders" and TreeViewX will only have access to Orders and Order_Details.

Visual C++

The following Visual C++ tutorials are offered:

  • Binding using ADO DC at Design-Time, Non-Hierarchical
  • Binding using ADO DC at Run-Time, Non-Hierarchical
  • Binding using OLE DB at Run-Time, Non-Hierarchical
  • Binding using ADO DC at Design-Time, Hierarchical
  • Binding using OLE DB at Run-Time, Hierarchical

Binding using ADO DC at Design-Time, Non-Hierarchical

(Note: At the time of this release, design-time data binding in Visual C++ 6.0 is disabled. All data-binding should be done at run-time)

  1. Run Microsoft VC++ 6.0
  2. Select File | New
  3. On the Projects tab, select "MFC AppWizard (exe)"
  4. Enter the location for the project
  5. For this sample, we will use the name "vcsamp" for the Project name.
  6. Make sure "Create new workspace" is selected, and Platforms is "Win32"
  7. Click on OK
  8. Select "Dialog Based"
  9. Click Finish, click OK
  10. From the main menu, select Project | Add to Project | Components and Controls
  11. Double-click the folder "Registered ActiveX Controls"
  12. Scroll over to "Microsoft ADO Data Control ..." and double-click on it.
  13. Click on OK to insert the component
  14. Click on OK to generate the classes
  15. Repeat steps 12-14 for "ProtoView TreeViewX v3.0"
  16. Click on Close to close the Components and Controls Gallery
  17. Delete the "TODO:" static field from the dialog
  18. Place a TreeViewX control on your dialog, and the ADO DC
  19. Right-click on the ADO DC and select "Properties"
  20. On the Control tab, select "Use ODBC Data Source Name"
  21. Select your "Jet NorthWind connection" -- You may need to set this up through the ODBC 32-bit Administrator through your Control Panel beforehand (or select New)
  22. On the "RecordSource" Property page, select "adCmdTable" from the "Command Type" combobox
  23. Select the "Customers" table from the "Table or Stored Procedure Name" combobox
  24. Close the properties window
  25. Right-click on TreeViewX and select "Properties"
  26. Click on the right-arrow to move to the All property page and view the All property page
  27. Change the DataSource property to IDC_ADODC1
  28. Move the the Data-Binding property page
  29. Double-click on "CompanyName"
  30. Close the property window
  31. Build and run your application

Binding using ADO DC at Run-Time, Non-Hierarchical

  1. Start Microsoft Visual C++
  2. Select File | New from the main menu
  3. On the Projects tab, select "MFC AppWizard (exe)"
  4. Enter a location and name for the project. In this sample, we will use vcsamp again
  5. Click OK
  6. Select "Dialog Based", then click Finish
  7. Click OK
  8. From the main menu, select Project | Add to Project | Components and Controls
  9. Double-click on the Registered AcitveX Controls
  10. Scroll over to "Microsoft ADO Data Control" and double-click on it
  11. Click OK to insert the component, click OK to generate the classes
  12. Repeat steps 10 & 11 for "ProtoView TreeViewX v3.0"
  13. Click on Close to close the Components and Control Gallery
  14. Delete the TODO static field on the dialog, then place TreeViewX and an ADO DC on the dialog
  15. Right-click on the ADO DC and select Properties
  16. On the Control tab, select Use ODBC Data Source Name, and select your NorthWind Jet Data Source. You may need to set this up through your 32-bit ODBC Administrator in Control Panel beforehand.
  17. On the RecordSource tab, select adCmdTable under the Command Type combobox
  18. Select "Customers" in the Table or Stored Procedure Name combobox
  19. Close the Properties dialog
  20. Press Ctrl-W to enter ClassWizard (or select it from the View menu)
  21. On the Member Variables tab, double-click on IDC_ADODC1.
  22. Give this control the name m_adodc. Make sure the Category is Control and Variable type is Cadodc, then click OK
  23. Double-click on IDC_PVTREEVIEWXCTRL1
  24. Give this control the name m_treeview. Make sure the Category is Control and Variable type is CPVTreeView3, then click OK.
  25. On the Message Maps tab, you should have OnInitDialog listed under the Member functions. Double-click on it to edit the code
  26. Look for "// TODO: Add extra initialization here" in the function and add the following lines of code after the todo line, but before "return TRUE":

    m_adodc.Refresh();
    m_treeview.SetDataField(0, "CompanyName");
    m_treeview..SetDataSource(m_adodc.GetRecordset().GetDataSource());

    At the top of the file, add:

    #include "_recordset.h"
  27. Build and run your application.

Binding using OLE DB at Run-Time, Non-Hierarchical

This sample will show how to bind TreeViewX without the use of a data control at run-time.

  1. Start Microsoft Visual C++
  2. Select File | New from the main menu
  3. On the Projects tab, select "MFC AppWizard (exe)"
  4. Enter a location and name for the project. In this sample, we will use vcsamp again
  5. Click OK
  6. Select "Dialog Based", then click Finish
  7. Click OK
  8. From the main menu, select Project | Add to Project | Components and Controls
  9. Double-click on the Registered AcitveX Controls
  10. Scroll over to "ProtoView TreeViewX v3.0" and double-click on it
  11. Click OK to insert the component, click OK to generate the classes
  12. Click on Close to close the Components and Control Gallery
  13. Delete the TODO static field on the dialog, then place a TreeViewX on the dialog
  14. Press Ctrl-W to enter ClassWizard (or select it from the View menu)
  15. On the Member Variables tab, double-click on IDC_PVTREEVIEWXCTRL1
  16. Give this control the name m_treeview. Make sure the Category is Control and Variable type is CPVTreeView3, then click OK.
  17. On the Class Info tab, click on Add Class and select From a type library...
  18. Locate msado15.dll (typically in the /Program Files/Common Files/System/ado directory), and double-click on it.
  19. Select all the classes, and click on OK to generate the files
  20. On the Message Maps tab, select "CvcsampDlg" under Object Ids listbox.
  21. In the Message listbox, double-click on WM_CLOSE. This will add the member function to your application.
  22. On the Message Maps tab, you should have OnInitDialog listed under the Member functions. Double-click on it to edit the code
  23. Look for "// TODO: Add extra initialization here" in the function and add the following lines of code after this line, but before "return TRUE":

    // Your DSN=...; may be different. Please refer to your 32-bit ODBC Administrator

    // in Control Panel to get the correct name.

    COleVariant Connect( "DSN=OLE_DB_NWind_Jet;UID=;PWD=;" );

    COleVariant Source ( "SELECT * FROM Customers" );

    Rs1.CreateDispatch( "ADODB.Recordset.2.0", &e );

    Rs1.Open( (VARIANT) Source, (VARIANT) Connect, 0, 1, -1 );

    m_datatbl.SetAllowDBAutoConfig(TRUE);

    m_datatbl.SetDataSource(Rs1.GetDataSource());

  24. Locate the function void CVcsampDlg::OnClose() in the .cpp file.
  25. Right after the TODO marker and before the CDialog::OnClose(), add the following two lines before the "CDialog::OnClose" line:

    Rs1.Close();

    Rs1.ReleaseDispatch();

  26. Open the header file for this dialog, vcsampDlg.h
  27. Locate the following thress lines:

    //{{AFX_INCLUDES()
    #include "pvtreeview3.h"
    //}}AFX_INCLUDES
  28. Add the following line after it:

    #include "msado15.h"
  29. Locate the constructor, and directly after it, add the following two lines:

    _Recordset Rs1;
    COleException e;
  30. Save and close the header file
  31. Build and run your application

Binding using ADO DC at Design-Time, Hierarchical

This sample will show TreeViewX being bound at design-time to the ADO DC hierarchically

(Note: At the time of this release, design-time data binding in Visual C++ 6.0 is disabled. All data-binding should be done at run-time)

  1. Run Microsoft VC++ 6.0
  2. Select File | New
  3. On the Projects tab, select "MFC AppWizard (exe)"
  4. Enter the location for the project
  5. For this sample, we will use the name "vcsamp" for the Project name.
  6. Make sure "Create new workspace" is selected, and Platforms is "Win32"
  7. Click on OK
  8. Select "Dialog Based"
  9. Click Finish, click OK
  10. From the main menu, select Project | Add to Project | Components and Controls
  11. Double-click the folder "Registered ActiveX Controls"
  12. Scroll over to "Microsoft ADO Data Control ..." and double-click on it.
  13. Click on OK to insert the component
  14. Click on OK to generate the classes
  15. Repeat steps 12-14 for "ProtoView TreeViewX v3.0"
  16. Click on Close to close the Components and Controls Gallery
  17. Delete the "TODO:" static field from the dialog
  18. Place a TreeViewX control and the ADO DC on your dialog.
  19. Right-click on the ADO DC and select "Properties"
  20. On the Control tab, select Use Connection String, and click on Build
  21. Click on MSDataShape, then click on Next
  22. On the Connection tab, enter the Data Source name for the NorthWind Jet Database in the Data Source field.
  23. Click on Test Connection. If it succeeds, click on OK and go to the next step. If it fails, then check your setting on this page. The only field that should be filled in it the Data Source field. The Data Source name you specify should match the name in your 32-bit ODBC Administrator.
  24. Right-click on the ADO DC again and select Properties to bring up the Properties dialog
  25. On the RecordSource tab, select adCmdText in the Command Type combobox
  26. In the CommandText (SQL) Edit field, enter in the following command:

    SHAPE {select * from Customers} APPEND ({select * from Orders} AS chapter RELATE CustomerID TO CustomerID)

    NOTE: For information on this command, please refer to the Microsoft help files.
  27. Close the Properties Dialog
  28. Right-click on TreeViewX, and select Properties
  29. On the All Property page, set the Data Source property to IDC_ADODC1
  30. Close the Properties Dialog
  31. Build and run your application

Binding using OLE DB at Run-Time, Hierarchical

  1. Start Microsoft Visual C++
  2. Select File | New from the main menu
  3. On the Projects tab, select "MFC AppWizard (exe)"
  4. Enter a location and name for the project. In this sample, we will use vcsamp again
  5. Click OK
  6. Select "Dialog Based", then click Finish
  7. Click OK
  8. From the main menu, select Project | Add to Project | Components and Controls
  9. Double-click on the Registered AcitveX Controls
  10. Scroll over to "ProtoView TreeViewX v3.0" and double-click on it
  11. Click OK to insert the component, click OK to generate the classes
  12. Click on Close to close the Components and Control Gallery
  13. Delete the TODO static field on the dialog, then place a TreeViewX on the dialog
  14. Press Ctrl-W to enter ClassWizard (or select it from the View menu)
  15. On the Member Variables tab, double-click on IDC_PVTREEVIEWXCTRL1
  16. Give this control the name m_treeview. Make sure the Category is Control and Variable type is CPVTreeView3, then click on OK.
  17. On the Class Info tab, click on Add Class and select From a type library...
  18. Locate msado15.dll (typically in the /Program Files/Common Files/ado directory), and double-click on it.
  19. Select all the classes, and click on OK to generate the files
  20. On the Message Maps tab, select "CvcsampDlg" under Object Ids listbox.
  21. In the Messages listbox, double-click on WM_CLOSE. This will add the member function to your application.
  22. On the Message Maps tab, you should have OnInitDialog listed under the Member functions. Double-click on it to edit the code
  23. Look for "// TODO: Add extra initialization here" in the function and add the following lines of code after this line, but before "return TRUE":

    // Your DSN=...; may be different. Please refer to your 32-bit ODBC Administrator
    // in Control Panel to get the correct name.
    COleVariant Connect( "Provider=MSDataShape;DSN=OLE_DB_NWind_Jet;UID=;PWD=;" );

    COleVariant
    Source ( "SHAPE {select * from Customers} APPEND ({select * from Orders} AS chapter
    RELATE CustomerID TO CustomerID)" );
Rs1.CreateDispatch( "ADODB.Recordset.2.0", &e );
Rs1.Open( (VARIANT) Source, (VARIANT) Connect, 0, 1, -1 );

m_treeview.SetDataField(0, "Customers.CompanyName");

    m_treeview.SetDataField(1, "Orders.OrderID");

    m_treeview.SetDataSource(Rs1.GetDataSource());

    (Move this into its own sample)
    For Visual Basic, the code is as follows:

    Dim con As New ADODB.Connection

    Dim rs1 As New ADODB.Recordset

    con.Open "Provider=MSDataShape;DSN=OLE_DB_NWind_Jet;UID=;PWD=;"

    rs1.Open "SHAPE {select * from Customers} APPEND ({select * from Orders} AS Orders RELATE CustomerID TO CustomerID)", "Provider=MSDataShape;DSN=OLE_DB_NWind_Jet;UID=;PWD=;"

    PVTreeViewX1.DataField(0) = "Customers.CompanyName"

    PVTreeViewX1.DataField(1) = "Orders.OrderID"

    Set PVTreeViewX1.DataSource = rs1

  24. Locate the function void CVcsampDlg::OnClose() in the .cpp file.
  25. Right after the TODO marker and before the CDialog::OnClose(), add the following two lines:

    Rs1.Close();

    Rs1.ReleaseDispatch();

  26. Open the header file for this dialog, vcsampDlg.h
  27. Locate the following thress lines:

    //{{AFX_INCLUDES()
    #include "pvtreeview3.h"
    //}}AFX_INCLUDES
  28. Add the following line after it:

    #include "msado15.h"
  29. Locate the constructor, and directly after it, add the following two lines:

    _Recordset Rs1;
    COleException e;
  30. Save and close the header file
  31. Build and run your application

The samples above should give you a good idea on how to do some fairly complex data-binding. The previous tutorials should capture just about every aspect of data-binding. The following tutorials will show how to accomplish data-binding in Java (Visual J++) and several example of data-binding for Internet Development including RDS and ADO.

Visual J++

The following Visual J++ tutorials are offered:

  • Binding Using OLE DB at Run-Time

Binding using OLE DB at Run-Time

  1. Run Microsoft Visual J++ 6.0
  2. If the "New Project" dialog box does not come up, choose File | New Project
  3. Select the Visual J++ Projects | Applications in the TreeView.
  4. Select Appliciation Wizard in the ListView.
  5. Enter a location and name. For this sample we will use jsamp.
  6. Click on Open
  7. Click on Next
  8. Select Form Based Application with Data, and click on Next
  9. Select ODBC and click on Next
  10. Select your NorthWind Jet DSN and click on Next
  11. Select Single record under Form layout, and click on Code, then click on Next
  12. Select Customers under the Record source combobox
  13. Move all fields to the right listbox
  14. Click on Finish
  15. On the Toolbox, right-click on the background and select "Customize toolbox..."
  16. On the ActiveX Controls tab, include ProtoView TreeViewX v3.0 and click on OK
  17. Select TreeViewX from the tools palette and place it on your dialog (after you make room for it)
  18. Right-click on the background of the dialog, and select View Code
  19. Search for the function "void openDataConnection()"
  20. Add the following lines as the last lines in the function:

    PVTreeViewX1.setDataField(0, new String("CompanyName"));
    PVTreeViewX1.setDataSource((msdatsrc.DataSource) m_rs.getDataSource());

    The typecasting is necessary here. Hopefully, as Visual J++ progresses to the point of Visual C++ or Visual Basic, this won&rsquo;t be necessary.
  21. Build and run your project

As you&rsquo;ll notice in this function, all the code is spelled out here on creating a recordset. You can simply modify this to make it hierarchical using the samples above.

Design-time data-binding is not available as of yet, so there are no samples for it in Java.

HTML and ASP

The following HTML and ASP tutorials are offered:

  • Binding Using RDS at Design-Time

Binding using RDS at Design-Time

This sample assumes you already have the AdvWorks sample installed an running correctly on your IIS Server. If you do not have this sample, you can obtain it from http://www.microsoft.com/data/rds.

  1. Start Microsoft Visual InterDev 6.0 and either open up an existing Web Project containing the AdvWorks sample, or create a new Web Project using the AdvWorks Web. For information on how to do this, please refer to Microsoft&rsquo;s InterDev help files.
  2. From the Project Explorer Window, right-click on <myserver>/<myWebProject> and select Add | Active Server Page...
  3. Select the Existing tab
  4. Move the the PVApps/TreeViewX/Samples/HTML/RDS directory (or PVApps/ActiveXSuite3/Samples/HTML/RDS
  5. Select the RDSTEMPLATE.ASP file and click on Open.
    This will add the page to your Web Project
  6. In the Project Explorer, double-click on RDSTEMPLE.ASP to open it.
    You will get a message box saying that an object failed to load and will be open as text. This is okay. It is the RDS Data Control. The RDS Data Control is not really a control, rather it is installed on the client side as part of Internet Explorer 4.x.
  7. If you do not already have TreeViewX on your Tools palette, right-click on the Tools Palette and choose Customize Toolbox. On the ActiveX Controls tab, check ProtoView TreeViewX v3.0 and click OK
  8. You should see a line with the following text:
    <!-- Insert ActiveX Controls here -->

    Drag TreeViewX from the Tools Palette and position it after this line.

    Because of the Design-time limitations of Visual InterDev, we will need to modify the Object Tag for TreeViewX to set the DataSource property. Right-click on TreeViewX and select "Always View As Text". The first line should appear as follows:

    <OBJECT classid="clsid:DB625B9A-05EA-11D2-97DD-00400520799C" id=PVTreeViewX1 style="LEFT: 0px; TOP: 0px" VIEWASTEXT>

  9. Scroll to the last line of the OBJECT tag, add this following paramater as the last one (don&rsquo;t forget to move the </OBJECT> to appear after the parameter you add):

    <PARAM NAME=DataSource dataSrc=#ADC>

    <OBJECT classid="clsid:DB625B9A-05EA-11D2-97DD-00400520799C" id=PVTreeViewX1 style="LEFT: 0px; TOP: 0px" VIEWASTEXT>
    <PARAM NAME="_Version" VALUE="196608">
    <PARAM NAME="_ExtentX" VALUE="5291">
    <PARAM NAME="_ExtentY" VALUE="4762">
    ...
    <PARAM NAME="DataField16" VALUE="">
    <PARAM NAME="DataField17" VALUE="">
    <PARAM NAME="DataField18" VALUE="">
    <PARAM NAME="DataField19" VALUE="">
    <PARAM NAME=DataSource dataSrc=#ADC></OBJECT>

    One of the PARAMs should be DataField0, in this sample, we will set the field for simplicity. Modify the line that reads:

    <PARAM NAME="DataField0" VALUE="">

    To read:

    <PARAM NAME="DataField0" VALUE="ProductCode">

    NOTE: If you want to set the DataField0 at run-time, you could do that in the OnLoad routine as follows:

    ...

    Server.Value = "http://<%=Request.ServerVariables("SERVER_NAME")%>"

    Connect.Value = "DSN=AdvWorks"

    SQL.Value = "Select * from Products"

    PVTreeViewX1.DataField(0) = "ProductCode"

    ...

  10. Save the file (it should update your Web on the server) and view it in your browser. When the page comes up, click on Run.


ProtoView TreeView Control

ProtoView TreeViewX Control

The ProtoView TreeViewX control is a hierarchical list box control suitable for displaying lists of items in a hierarchical manner. The TreeViewX control is similar to the Microsoft treeview control; however, the WinX version adds a number of important features, such as multi-column support, easier node traversal, customize pictures, and data binding.

Binding

The TreeViewX control can be bound to a data source and display a single column of data from a flat record source, or a column for each table in a hierarchical data source. This is done by assigning the DataSource property to an appropriate data control or record source, and then setting the DataField property to a single column in the data source (once per table). When the TreeVie wX control is bound, two events, BeforeDBAddNode and AfterDBAddNode are fired before and after a node is added to the TreeView, respectively. Developers can use the BeforeDBAddNode event to abort the addition of the node or to customize the text of the branch, and the AfterDBAddNode event to add sub-items to the node.

The following code demonstrates binding to a hierarchical result set with three levels. Each level of the TreeViewX can display a single column of the corresponding table in the record set.

TreeViewX.DataSource = ADODC1
TreeViewX.DataField(0) = "LastName"
TreeViewX.DataField(1) = "Product"
TreeViewX.DataField(2) = "Quantity"

TreeViewX Properties

List of Properties

The ProtoView TreeViewX control supports the following properties:

AllowInPlaceEditing

AlwaysShowSelection

Appearance*

AutoOpen

BackColor*

BorderStyle*

Branches

ColumnWidth

Count

CustomDefaultPicture

CustomLevelPicture

DataField

DataSource

Enabled*

EnableBitmaps

EnableLines

EnableMicroBitmaps

EnableToolTips

Font*

ForeColor*

HorizontalExtent

hWnd*

Indent

IntegralHeight

LineColor

MultiColumn

MultiColumnStyle

NumberOfColumns

ProportionalScrollBars

Redraw

SelectedTextBackColor

SelectedTextForeColor

SelectMode

Sort

StandardDefaultPicture

StandardLevelPicture

TabPoint

TabPointCount

ToolTipBackColor

UseStateBitmaps

UseTabStops

VisibleCount

* This is a common property described in the Appendix: Common Properties, Methods and Events.

AllowInPlaceEditing

Returns or sets a value that determines whether a TreeViewX control will allow direct modification of a branch's text.

Syntax

Visual Basic

object.AllowInPlaceEditing = boolean
boolean = object.AllowInPlaceEditing

Visual C++

object.SetAllowInPlaceEditing(boolean);
boolean = object.GetAllowInPlaceEditing( );

Delphi

object.AllowInPlaceEditing := boolean;
boolean := object.AllowInPlaceEditing;

The AllowInPlaceEditing property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will allow in-place editing.

Settings

The settings for boolean are:

Setting | Description
True | Allows direct modification of branch's text.
False | Makes all branch object's read-only.

AlwaysShowSelection

Returns or sets the selection display state of a TreeViewX control.

Syntax

Visual Basic

object.AlwaysShowSelection = boolean
boolean = object.AlwaysShowSelection

Visual C++

object.SetAlwaysShowSelection ( boolean );
boolean = object.GetAlwaysShowSelection( );

Delphi

object.AlwaysShowSelection := boolean;
boolean := object.AlwaysShowSelection;

The AlwaysShowSelection property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether the selection state remains constant when the TreeViewX control looses focus.

Settings

The settings for boolean are:

Setting | Description
True | The selected item(s) in the TreeViewX control are always painted with the highlight background color.
False | (Default) The selected item(s) in the TreeViewX control are painted with the highlight background color only when the control has focus.

Remarks

This property should normally be set to False (the default value) to comply with Microsofts’ interface design guidelines for Windows programs.

AutoOpen

Returns or sets the auto open state of the TreeViewX control.

Syntax

Visual Basic

object.AutoOpen = boolean
boolean = object.AutoOpen

Visual C++

object.SetAutoOpen ( boolean );
boolean = object.GetAutoOpen( );

Delphi

object.AutoOpen := boolean;
boolean := object.AutoOpen;

The AutoOpen property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether the parent item will automatically open when a child is added.

Settings

The settings for boolean are:

Setting | Description
True | Items of the TreeViewX control automatically open the first time a child item is added to the item.
False | (Default) Items of the TreeViewX control do not automatically open when child items are added.

Remarks

The AutoOpen property only affects an item when the first child is added to it. This property is ignored for subsequent child items. This property is also ignored if any of the items’ parent items are closed or if the item is locked.

Branches

The Branches property returns the list of items in a TreeViewX control. Read only at run time, not available at design time.

Syntax

Visual Basic

branch = object.Branches

Visual C++

branch = object.GetBranches( );

Delphi

branch := object.Branches;

The object placeholder represents an object expression that evaluates to TreeViewX control.

Part | Description
object | A TreeViewX object.
branch | A branch object.

Remarks

The Branches property returns a Branch Object, through which you can manipulate items in a TreeViewX control.

The Branch object returned by this property is the main Branch. As such it does not correspond to a TreeViewX control item per se, as do all other Branches. However, you can use its methods to gain access to all other items in the TreeViewX control.

ColumnWidth

The ColumnWidth property sets or returns the width of an individual column in the TreeViewX control.

Syntax

Visual Basic

object.ColumnWidth = value
value = object.ColumnWidth

Visual C++

object.SetColumnWidth (value);
value = object.GetColumnWidth( );

Delphi

object.ColumnWidth:= value;
value := object.ColumnWidth;

The ColumnWidth property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer or constant that determines the column width, in pixels, of an individual column in a multicolumnK TreeViewX control.

Remarks

The ColumnWidth property only affects a multicolumn / fixed column width TreeViewX control. That is to say, the TreeViewX control must have its MultiColumn Property set to True, and its MultiColumnStyle Property set to 0 for this property to have any effect.

Count

The Count property returns the total number of items in a TreeViewX control. Read only at run timeK, not available at design time.

Syntax

Visual Basic

value = object.Count

Visual C++

value = object.GetCount( );

Delphi

value := object.Count;

Part | Description
object | A TreeViewX object.
value | A long integer which contains the number of items in the TreeViewX control.

Remarks

The Count property is a read only variable at run timeK.

CustomDefaultPicture

The CustomDefaultPicture property sets or returns the default picture displayed next to each item on the TreeViewX control.

Syntax

Visual Basic

object.CustomDefaultPicture = picture
picture = object.CustomDefaultPicture

Visual C++

object.SetCustomDefaultPicture (picture);
picture = object.GetCustomDefaultPicture( );

Delphi

object.CustomDefaultPicture:= picture;
picture := object.CustomDefaultPicture;

The CustomDefaultPicture property syntax has these parts:

Part | Description
object | A TreeViewX object.
picture | A picture object which contains a graphic, as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

Please see the Remarks for TreeViewX images.

CustomLevelPicture

The CustomLevelPicture property sets or returns the default picture displayed next to each item on the TreeViewX control on a particular level.

Syntax

Visual Basic

object.CustomLevelPicture(level) = picture
picture = object.CustomLevelPicture(level)

Visual C++

object.SetCustomLevelPicture (level, picture);
picture = object.GetCustomLevelPicture(level);

Delphi

object.CustomLevelPicture[level] := picture;
picture := object.CustomLevelPicture[level];

The CustomLevelPicture property syntax has these parts:

Part | Description
object | A TreeViewX object.
level | A short integer that specifies the level for which the default picture is to be set.
picture | A picture object which contains a graphic, as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

Please see the Remarks for TreeViewX images.

DataField

Returns or sets the column name TreeViewX uses to display values from the data source for each level of the treeview.

Syntax

Visual Basic

object.DataField(level) = value
value = object.DataField(level)

Visual C++

object.SetDataFielde (level, value);
value = object.GetDataField(level);

Delphi

object.DataField[level] := value;
value := object.DataField[level];

The CustomLevelPicture property syntax has these parts:

Part | Description
object | A TreeViewX object.
level | A long integer specifying the level for the column values to be displayed.
value | A string representing a column in the database.

Remarks

TreeViewX is bound to a database by specifying a Data control in the DataSource property at design time using the Properties window or by setting the DataSource property at runtime. A column in the database is bound to a the TreeViewX by using the DataField property of the TreeViewX. See the comments on data binding to the TreeView.

Example

The following code demonstrates binding to a hierarchical result set with three levels. Each level of the TreeViewX can display a single column of the corresponding table in the record set.

TreeViewX.DataSource = ADODC1
TreeViewX.DataField(0) = "LastName"
TreeViewX.DataField(1) = "Product"
TreeViewX.DataField(2) = "Quantity"

DataSource

Sets a value that specifies the Data control through which the TreeViewX is bound to a database.

Remarks

TreeViewX is bound to a database by specifying a Data control in the DataSource property at design time using the Properties window or by setting the DataSource property at runtime. A column in the database is bound to the TreeViewX by using the DataField property of the TreeViewX. See the comments on data binding to the TreeView.

EnableBitmaps

Returns or sets a value that determines whether a TreeViewX control will display images next to each item in the control.

Syntax

Visual Basic

object.EnableBitmaps = boolean
boolean = object.EnableBitmaps

Visual C++

object.SetEnableBitmaps (boolean);
boolean = object.GetEnableBitmaps( );

Delphi

object.EnableBitmap := boolean;
boolean:= object.EnableBitmaps;

The EnableBitmaps property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will display images next to each item.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The TreeViewX will display images next to items.
False | The TreeViewX will display no images next to items.

Remarks

The EnableBitmaps property allows the TreeViewX control to display an image next to each item at run time. The item to be displayed depends on a number of other settings.

Please see the Remarks for TreeViewX images.

EnableLines

Returns or sets a value that determines whether a TreeViewX control will display lines connecting parent items to their children.

Syntax

Visual Basic

object.EnableLines = boolean
boolean = object.EnableLines

Visual C++

object.SetEnableLines(boolean);
boolean = object.GetEnableLines( );

Delphi

object.EnableLines := boolean;
boolean := object.EnableLines;

The EnableLines property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will display lines connecting parent items to their children.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Causes object to display lines connecting parent items to their children.
False | Prevents object from displaying lines connecting parent items to their children.

EnableMicroBitmaps

Returns or sets a value that determines whether a TreeViewX control will display a box containing either a "+" or "-" next to each item. A box with a "+" indicates that a closed item has children. Clicking on the "+" with the mouse will cause the item to open (display it’s children in the TreeViewX control). A box with a "-" indicates that the item has children and is open. Clicking on the "-" will cause the item to close.

Syntax

Visual Basic

object.EnableMicroBitmaps = boolean
boolean = object.EnableMicroBitmaps

Visual C++

object.SetEnableMicroBitmaps(boolean);
boolean = object.GetEnableMicroBitmaps( );

Delphi

object.EnableMicroBitmaps := boolean;
boolean := object.EnableMicroBitmaps;

The EnableMicroBitmaps property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will display a box containing either a "+" or "-" next to each item.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Causes object to display a box containing either a "+" or "-" next to each item.
False | Prevents object from displaying display a box containing either a "+" or "-" next to each item.

EnableToolTips

Returns or sets a value that determines whether a TreeViewX control will display tool tips when the mouse is over a branch object. A tool tip displays the entire text of a branch object, even if the branch object is clipped by the TreeViewX control.

Syntax

Visual Basic

object.EnableToolTips = boolean
boolean = object.EnableToolTips

Visual C++

object.SetEnableToolTips(boolean);
boolean = object.GetEnableToolTips( );

Delphi

object.EnableToolTips := boolean;
boolean := object.EnableToolTips;

The EnableToolTips property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will display tool tips.

Settings

The settings for boolean are:

Setting | Description
True | Causes object to display tool tips when the mouse is over a branch object.
False | Prevents object from displaying tool tips when the mouse is over a branch object.

HorizontalExtent

Returns or sets a value that determines the logical width of a TreeViewX control.

Syntax

Visual Basic

object.HorizontalExtent = value
value = object.HorizontalExtent

Visual C++

object.SetHorizontalExtent(value);
value = object.GetHorizontalExtent( );

Delphi

object.HorizontalExtent := value;
value := object.HorizontalExtent;

The HorizontalExtent property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer that specifies the logical width of a TreeViewX control. The logical width is specified in pixels.

Remarks

The HorizontalExtent property specifies the logical width of a TreeViewX at run time.

If the logical width of the control is less than the physical width (i.e., the actual width of the control in pixels as it appears on screen), then the HorizontalExtent property has no effect. If the logical width is greater than the physical width, a horizontal scroll bar appears at the bottom of the control to allow the user to scroll the contents of the TreeViewX control horizontally.

Indent

The Indent property sets or returns the amount of space, in pixels, that each subsequent child level is indented from its parent in the TreeViewX control.

Syntax

Visual Basic

object.Indent = value
value = object.Indent

Visual C++

object.SetIndent(value);
value = object.GetIndent( );

Delphi

object.Indent:= value;
value := object.Indent;

The Indent property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer or constant that determines the amount of space, in pixels, that each subsequent child level is indented from its parent in the TreeViewX control.

IntegralHeight

Returns or sets a value indicating if the control displays partial items. Read only at run time.

Syntax

Visual Basic

object.IntegralHeight = boolean
boolean = object.IntegralHeight

Visual C++

object.SetIntegralHeight(boolean);
boolean = object.GetIntegralHeight( );

Delphi

object.IntegralHeight := boolean;
boolean := object.IntegralHeight;

Part | Description
object | A TreeViewX object.
boolean | A Boolean expressionthat specifies whether object will resize itself to hide partial items.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The TreeViewX control resizes itself to display only complete items.
False | The TreeViewX control doesn't resize itself even if the item is too tall to display completely.

LineColor

Returns or sets the color used to draw lines connecting parent/child branch objects.

Syntax

Visual Basic

object.LineColor = color
color = object.LineColor

C++

object.SetLineColor(color);
color = object.GetLineColor();

Delphi

object.LineColor := color;
color := object.LineColor;

The LineColor property syntax has these parts:

Part | Description
object | A TreeViewX object.
color | A color value or constant as described in Settings.

Remarks

See the section Notes About Colors in the Appendix: Common Properties, Methods and Events

MultiColumn

Returns or sets a value indicating if the TreeViewX control displays the list of items in a multicolumn fashion. Read only at run time.

Syntax

Visual Basic

object.MultiColumn = boolean
boolean = object.MultiColumn

Visual C++

object.SetMultiColumn(boolean);
boolean = object.GetMultiColumn( );

Delphi

object.MultiColumn:= boolean;
boolean := object.MultiColumn;

The MultiColumn property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will display items in a multicolumn fashion.

Settings

The settings for boolean are:

Setting | Description
True | The TreeViewX control displays its items in a multicolumn fashion.
False | (Default) The TreeViewX control displays its items in the normal fashion.

Remarks

The TreeViewX control can display multicolumn lists in one of two modes: fixed column width mode and variable column width mode.

In the fixed column width mode (see MultiColumnStyle Property), you specify the width of each column using the ColumnWidth Property. In this mode, each column will remain a constant width no matter how the TreeViewX control is sized.

In the variable column width mode, you specify the number of columns to be displayed on the TreeViewX control by setting the NumberOfColumns Property. In this mode, the number of columns displayed on the TreeViewX control remains constant no matter how the TreeViewX control is sized.

MultiColumnStyle

Returns or sets a value indicating the style of the multicolumn display.

Syntax

Visual Basic

object.MultiColumnStyle = value
value = object.MultiColumnStyle

Visual C++

object.SetMultiColumnStyle(value);
value = object.GetMultiColumnStyle( );

Delphi

object.MultiColumnStyle:= value;
value:= object.MultiColumnStyle;

The MultiColumnStyle property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A constant that determines the multicolumn style, as described in Settings.

Settings

The settings for value are:

Setting | Description
pvtMuliColFixedWidth - 0 | (Default) Fixed. Specifies that the TreeViewX control displays its items in a fixed column width mode
pvtMultiColVariableWidth - 1 | Variable. Specifies that the TreeViewX control displays its items in a variable column width mode.

Remarks

The TreeViewX control can display multicolumn lists in one of two modes: fixed column width mode and variable column width mode.

In the fixed column width mode, you specify the width of each column using the ColumnWidth Property. In this mode, each column will remain a constant width no matter how the TreeViewX control is sized.

In the variable column width mode, you specify the number of columns to be displayed on the TreeViewX control by setting the NumberOfColumns Property. In this mode, the number of columns displayed on the TreeViewX control remains constant no matter how the TreeViewX control is sized.

NumberOfColumns

The NumberOfColumns property sets or returns the number of columns displayed in the TreeViewX control.

Syntax

Visual Basic

object.NumberOfColumns = value
value = object.NumberOfColumns

Visual C++

object.SetNumberOfColumns(value);
value = object.GetNumberOfColumns( );

Delphi

object.NumberOfColumns:= value;
value:= object.NumberOfColumns;

The NumberOfColumns property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer or constant specifies the number of columns displayed in a multicolumn TreeViewX control.

Remarks

The NumberOfColumns property only affects a multicolumn / variable column width TreeViewX control. That is to say, the TreeViewX control must have its MultiColumn Property set to True, and its MultiColumnStyle Property set to 1 for this property to have any effect.

ProportionalScrollBars

The ProportionalScrollBars property sets or returns a value which specifies whether or not the TreeViewX controls scroll bars are sized proportionally to the contents of the control.

Syntax

Visual Basic

object.ProportionalScrollBars = boolean
boolean = object.ProportionalScrollBars

Visual C++

object.SetProportionalScrollBars(boolean);
boolean = object.GetProportionalScrollBars( );

Delphi

object.ProportionalScrollBars:= boolean;
boolean:= object.ProportionalScrollBars;

The ProportionalScrollBars property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that determines whether the TreeViewX control displays its scroll bars proportionally sized to its contents.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The TreeViewX control displays its scroll bars proportionally sized to its contents.
False | The TreeViewX control displays its scroll bars in the normal fashion.

Redraw

Returns or sets whether redraw capabilities of the TreeViewX are on of off. Setting redraw capabilties off is useful when adding many items to the TreeViewX to reduce flicker and the amount of time required to add the items.

Syntax

Visual Basic

object.Redraw = boolean
boolean = object.Redraw

Visual C++

object.SetRedraw ( boolean );
boolean = object.GetRedraw( );

Delphi

object.Redraw := boolean;
boolean := object.Redraw;

The Redraw property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether the TreeViewX can repaint itself.

Settings

The settings for boolean are:

Setting | Description
True | The TreeViewX control can always repaint itself.
False | The TreeViewX control cannot repaint itself.

SelectedTextBackColor

Returns or sets the background color used to display selected branch objects.

Syntax

Visual Basic

object.SelectedTextBackColor = color
color = object.SelectedTextBackColor

C++

object.SetSelectedTextBackColor(color);
color = object.GetSelectedTextBackColor();

Delphi

object.SelectedTextBackColor := color;
color := object.SelectedTextBackColor;

The SelectedTextBackColor property syntax has these parts:

Part | Description
object | A TreeViewX object.
color | A color value or constant as described in Settings.

Remarks

See the section Notes About Colors in the Appendix: Common Properties, Methods and Events

SelectedTextForeColor

Returns or sets the foreground color used to display selected branch objects.

Syntax

Visual Basic

object.SelectedTextForeColor = color
color = object.SelectedTextForeColor

C++

object.SetSelectedTextForeColor(color);
color = object.GetSelectedTextForeColor();

Delphi

object.SelectedTextForeColor := color;
color := object.SelectedTextForeColor;

The SelectedTextForeColor property syntax has these parts:

Part | Description
object | A TreeViewX object.
color | A color value or constant as described in Settings.

Remarks

See the section Notes About Colors in the Appendix: Common Properties, Methods and Events

SelectMode

Returns or sets a value indicating whether a user can make multiple selections in TreeViewX control and how the multiple selections can be made.

Syntax

Visual Basic

object.SelectMode = value
value = object.SelectMode

Visual C++

object.SetSelectMode(value);
value = object.GetSelectMode( );

Delphi

object.SelectMode:= value;
value:= object.SelectMode;

The SelectMode property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer that determines the selection mode in the TreeView.

Settings

The settings for value are:

Setting | Description
pvtSelectDefault - 0 | (Default) Multiple selection isn't allowed.
pvtSelectSimple - 1 | Simple multiple selection. A mouse click or pressing the SPACEBAR selects or deselects an item in the list. (Arrow keys move the focus.)
pvtSelectMultiple - 2 | Extended multiple selection. Pressing SHIFT and clicking the mouse or pressing SHIFT and one of the arrow keys (UP ARROW, DOWN ARROW, LEFT ARROW, and RIGHT ARROW) extends the selection from the previously selected item to the current item. Pressing CTRL and clicking the mouse selects or deselects an item in the list.

Sort

Returns a value indicating whether the elements of a control are automatically sorted alphabetically.

Syntax

Visual Basic

boolean = object.Sort

Visual C++

boolean = object.GetSort( );

Delphi

boolean:= object.Sort;

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether object will sort items in the list.

Settings

The settings for boolean are:

Setting | Description
True | List items are sorted alphabetically (case-insensitive).
False | (Default) List items aren't sorted alphabetically.

Remarks

When this property is True, Visual Basic handles almost all necessary string processing to maintain alphabetic order, including changing the index numbers for items as required by the addition or removal of items.

Note Using the Add method to add an element to a specific location in the list may violate the sort order, and subsequent additions may not be correctly sorted.

StandardDefaultPicture

Returns or sets a value indicating the default picture that will be displayed next to an item in the TreeViewX control.

Syntax

Visual Basic

object.StandardDefaultPicture = value
value = object.StandardDefaultPicture

Visual C++

object.SetStandardDefaultPicture(value);
value = object.GetStandardDefaultPicture( );

Delphi

object.StandardDefaultPicture:= value;
value:= object.StandardDefaultPicture;

The StandardDefaultPicture property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A constant that determines the default picture that will be displayed next to an item in the TreeViewX control, as described in Settings.

Settings

The settings for value are:

Setting | Description
pvtNone | No picture.
pvtpicFolders | (Default) Folder Picture.
pvtpicBoxes1 | Boxes #1 Picture.
pvtpicDocument | Document Picture.
pvtpicHardDisk | Hard Disk Picture.
pvtpicProgram | Program File Picture.
pvtpicSystemFile | System File Picture.
pvtpicBoxes2 | Boxes #2 Picture.
pvtpicBoxes3 | Boxes #3 Picture.
pvtpicASCIIFile | ASCII File Picture.
pvtpicHelpFile | Help File Picture.

Remarks

Please see the Remarks for TreeViewX images.

StandardLevelPicture

Returns or sets a value indicating the default picture that will be displayed next to an item in the TreeViewX control on a particular level.

Syntax

Visual Basic

object.StandardLevelPicture(level) = value
value = object.StandardLevelPicture(level)

Visual C++

object.SetStandardLevelPicture(level, value);
value = object.GetStandardLevelPicture(level);

Delphi

object.StandardLevelPicture[level]:= value;
value:= object.StandardLevelPicture[level];

The StandardLevelPicture property syntax has these parts:

Part | Description
object | A TreeViewX object.
level | A numeric expression that specifies the level for which the default picture is to be set.
Value | A constant that determines the default picture that will be displayed next to an item in the TreeViewX control, as described in Settings.

Settings

The settings for value are:

Setting | Description
pvtNone | No picture.
pvtpicFolders | (Default) Folder Picture.
pvtpicBoxes1 | Boxes #1 Picture.
pvtpicDocument | Document Picture.
pvtpicHardDisk | Hard Disk Picture.
pvtpicProgram | Program File Picture.
pvtpicSystemFile | System File Picture.
pvtpicBoxes2 | Boxes #2 Picture.
pvtpicBoxes3 | Boxes #3 Picture.
pvtpicASCIIFile | ASCII File Picture.
pvtpicHelpFile | Help File Picture.

Remarks

Please see the Remarks for TreeViewX images.

TabPoint

The TabPoint property sets or returns the location of tab stops in the TreeViewX control.

Syntax

Visual Basic

object.TabPoint(index) = value
value = object.TabPoint(index)

Visual C++

object.SetTabPoint(index, value);
value = object.GetTabPoint(index);

Delphi

object.TabPoint[index]:= value;
value:= object.TabPoint[index];

The TabPoint property syntax has these parts:

Part | Description
object | A TreeViewX object.
index | A numeric expression or constant that specifies which tab point to set or return.
value | A short integer or constant specifies the tab stop location, in dialog box units, from the left side of the TreeViewX control.

Remarks

The TreeViewX control must have its UseTabStops Property set to True for this property to have any effect.

If no tab stops are specified for a control, the default tab stop is two dialog box units. If only one tab stop is specified, the list box will have tab stops separated by the distance specified by that single tab stop. If more than a single tab stop is defined, a tab stop will be set for each value specified.

A dialog box unit is a horizontal or vertical distance. One horizontal dialog box unit is equal to 0.25 of the current dialog box base-width unit. These units are computed based on the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog box base units, in pixels.

TabPointCount

The TabPointCount property returns the number of tab stops defined in the TreeViewX control. Read only at run time, not available at design time.

Syntax

Visual Basic

value = object.TabPointCount

Visual C++

value = object.GetTabPointCount( );

Delphi

value:= object.TabPointCount;

The TabPointCount property syntax has these parts:

Part | Description
object | A TreeViewX object.
value | A short integer which returns the number of tab stops defined in the TreeView.

Remarks

The TreeViewX control must have its UseTabStops Property set to True for this property to have any meaning.

If no tab stops are specified for a control, the default tab stop is two dialog box units. If only one tab stop is specified, the list box will have tab stops separated by the distance specified by that single tab stop. If more than a single tab stop is defined, a tab stop will be set for each value specified.

A dialog box unit is a horizontal or vertical distance. One horizontal dialog box unit is equal to 0.25 of the current dialog box base-width unit. These units are computed based on the height and width of the current system font. The GetDialogBaseUnits function returns the current dialog box base units, in pixels.

ToolTipBackColor

Returns or sets the background color used to tool tips, should the property EnableToolTips be set to true.

Syntax

Visual Basic

object.ToolTipBackColor = color
color = object.ToolTipBackColor

C++

object.SetToolTipBackColor(color);
color = object.GetToolTipBackColor();

Delphi

object.ToolTipBackColor := color;
color := object.ToolTipBackColor;

The ToolTipBackColor property syntax has these parts:

Part | Description
object | A TreeViewX object.
color | A color value or constant as described in Settings.

Remarks

See the section Notes About Colors in the Appendix: Common Properties, Methods and Events

UseStateBitmaps

The UseStateBitmaps property sets or returns a boolean value indicating whether or not the TreeViewX control uses state format bitmaps.

Syntax

Visual Basic

object.UseStateBitmaps = boolean
boolean = object.UseStateBitmaps

Visual C++

object.SetUseStateBitmaps(boolean);
boolean = object.GetUseStateBitmaps( );

Delphi

object.UseStateBitmaps:= boolean;
boolean:= object.UseStateBitmaps;

The UseStateBitmaps property syntax has these parts:

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether the TreeViewX control interprets custom bitmaps as state format bitmaps, as described in Settings.

Settings

The settings for boolean are:

Setting | Description
True | (Default) The TreeViewX control control interprets custom bitmaps as state format bitmaps.
False | The TreeViewX control control interprets custom bitmaps as normal bitmaps.

Remarks

When a custom bitmap is assigned to an item, the TreeViewX control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item.

{bmlt examp1.bmp}

A state formatted bitmap is a bitmap that consists of three images, each placed next to each other. Only one of the three images is displayed at any given time, depending on the state of the item. The first image is displayed when the Branch object has no children, the second image is displayed when the Branch object has children and is in the open state, and the third image is displayed when the Branch object has children and is in the closed state. Each image must be the same size as the other two. Thus, only one third of the entire bitmap is displayed at any given time.

UseTabStops

Returns a value indicating whether the TreeViewX control recognizes and expands tab characters when drawing its strings. The default tab positions are 2 dialog units. (A dialog unit is a horizontal or vertical distance. One horizontal dialog unit is equal to one-fourth of the current dialog base width unit. The dialog base units are computed based on the height and width of the current system font. The GetDialogBaseUnits Windows function returns the current dialog base units in pixels.) Read only at run time.

Syntax

Visual Basic

object.UseTabStops = boolean
boolean = object.UseTabStops

Visual C++

object.SetUseTabStops(boolean);
boolean = object.GetUseTabStops( );

Delphi

object.UseTabStops:= boolean;
boolean:= object.UseTabStops;

Part | Description
object | A TreeViewX object.
boolean | A Boolean expression that specifies whether the TreeViewX control will use tabstops.

Settings

The settings for boolean are:

Setting | Description
True | The TreeViewX control recognizes and expands tab characters when drawing its strings.
False | (Default) The TreeViewX control does not recognize and expand tab characters when drawing its strings.

VisibleCount

The VisibleCount property returns the total number of visible items in a TreeViewX control. Read only at run time, not available at design time.

Syntax

Visual Basic

value = object. VisibleCount

Visual C++

value = object.GetVisibleCount( );

Delphi

value:= object. VisibleCount;

Part | Description
object | A TreeViewX object.
value | A long integer that returns the number of visible items in the TreeViewX control.

Remarks

Visible items are items whose parent items are all open, as opposed to an invisible item which has one or more of its parent items closed.

TreeViewX Methods

List of Methods

The ProtoView TreeViewX control supports the following methods:

AboutBox*

BeginInPlaceEdit

ClearTabStops

EndInPlaceEdit

Find

GetEditHWHD

HitTest

* This is a common method described in the Appendix: Common Properties, Methods and Events.

BeginInPlaceEdit

Puts the current Branch object into in-place edit mode.

Syntax

Visual Basic

object.BeginInPlaceEdit

Visual C++

object.BeginInPlaceEdit( );

Delphi

object.BeginInPlaceEdit;

The BeginInPlaceEdit method syntax has these parts:

Part | Description
object | A TreeViewX object.

ClearTabStops

Clears all tab stops in a TreeViewX Control.

Syntax

Visual Basic

object.ClearTabStops

Visual C++

object.ClearTabStops( );

Delphi

object.ClearTabStops;

The ClearTabStops method syntax has these parts:

Part | Description
object | A TreeViewX object.

Remarks

To remove one tab stop from a TreeViewX control, use the TabPoint Property to set the tab stop to -1.

EndInPlaceEdit

Ends the in-place editing of the current Branch object.

Syntax

Visual Basic

object.EndInPlaceEdit

Visual C++

object.EndInPlaceEdit( );

Delphi

object.EndInPlaceEdit;

The EndInPlaceEdit method syntax has these parts:

Part | Description
object | A TreeViewX object.

Find

Searches for a specific item in a TreeViewX control.

Syntax

Visual Basic

object.Find relationship, relative, text

Visual C++

object.Find( relationship, relative, text );

Delphi

object.Find(relationship, relative, text );

The Find method syntax has these parts:

Part | Description
object | A TreeViewX object.
relationship | A constant that specifies how the search for the item will proceed. This value can take on one of the manifest constants described in Settings.
relative | A Branch object that specifies the relative item.
text | A string that specifies the text string to search for.

Settings

The settings for relationship are:

pvtFindNext

Searches for the item following relative whose Text Property begins with text string.

pvtFindNextExact

Searches for the item following relative whose Text Property exactly matches text string.

pvtFindPrevious

Searches for the item prior to relative whose Text Property begins with text string.

pvtFindPreviousExact

Searches for the item prior to relative whose Text Propertyn exactly matches text string.

pvtFindNextSibling

Searches for the item following relative that shares the same parent as relative and whose Text Property begins with text string.

pvtFindNextSiblingExact

Searches for the item following relative that shares the same parent as relative and whose Text Property exactly matches text string.

pvtFindPreviousSibling

Searches for the item prior to relative that shares the same parent as relative and whose Text Property begins with text string.

pvtFindPreviousSiblingExact

Searches for the item prior to relative that shares the same parent as relative and whose Text Property exactly matches text string.

pvtFindNextVisible

Searches for the item following relative that is visible (i.e., an item whose parents areall open) and whose Text Property begins with text string.

pvtFindNextVisibleExact

Searches for the item following relative that is visible (i.e., an item whose parents areall open) and whose Text Property exactly matches text string.

pvtFindPreviousVisible

Searches for the item prior to relative that is visible (i.e., an item whose parents areall open) and whose Text Property begins with text string.

pvtFindPreviousVisibleExact

Searches for the item prior to relative that is visible (i.e., an item whose parents areall open) and whose Text Property exactly matches text string.

Remarks

The Find method returns a Branch Object that matches the search criteria. If no item matches the search criteria, an empty Branch object is returned.

You can use the Get method to obtain a Branch object that has a specific hierarchical relationship to a given item.

Visual Basic Example

This example searches the tree for the first Branch object that matches a partial string "Ar" in a TreeViewX control. That is to say, the Find method will find the first node in the tree that has a caption that begins with "Ar". To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Find (mnuFind). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuFind_Click ()
Dim node As Branch

Set node = PTreeView1.Find(FindNext, NULL, "Ar")

End Sub

GetEditHWND

Returns a handle to a the edit control where in-place editing for a TreeViewX control occurs.

Syntax

Visual Basic

hWnd = object.GetEditHWND

Visual C++

hWnd = object.GetEditHWND( );

Delphi

hWnd := object.GetEditHWND;

The GetEditHWND property syntax has these parts:

Part | Description
object | A TreeViewX object.
hWnd | A handle which contains the windows handle of the edit control.

Remarks

The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

Note Because the value of this property can change while a program is running, never store the hWnd value in a variable.

HitTest

Tries to locate a branch object at a specific spot in the TreeViewX control. The x, y coordinate is pixels relative to the upper left corner of the TreeViewX control. If a branch object is located at that position, a Branch object will be returned. If no branch object is at the spot, then a Branch object which returns false to IsValid is returned.

Syntax

Visual Basic

object.HitTest x, y

Visual C++

object.HitTest( x, y );

Delphi

object.HitTest( x, y );

The HitTest method syntax has these parts:

Part | Description
object | A TreeViewX object.
x | The x coordinate to hittest.
y | The y coordinate to hittest.

TreeViewX Events

List of Events

The ProtoView TreeViewX control supports the following events:

AfterCollapse

AfterDBAddNode

AfterExpand

AfterSelChange

BeforeCollapse

BeforeDBAddNode

BeforeExpand

BeforeSelChange

DeleteItem

KeyDown*

KeyPress*

KeyUp*

InPlaceEditBegin

InPlaceEditEnd

LButtonDblClick

LButtonDown

LButtonUp

RButtonDblClick

RButtonDown

RButtonUp

* This is a common event described in the Appendix: Common Properties, Methods and Events.

AfterCollapse

The AfterCollapse event is fired after an item has been collapsed (closed).

Syntax

Visual Basic

Private Sub object_AfterCollapse(Node)

Visual C++

OnAfterCollapseObject(Node);

Delphi

Procedure AfterCollapse(Sender, Node);

The AfterCollapse event syntax has these parts:

Part | Description
Node | A Branch object that has been collapsed.

Remarks

When a node is collapsed in the TreeViewX control, the TreeViewX control fires the BeforeCollapse event before the node is collapsed. The user may cancel the collapse event by setting the bProcessed variable to True. If the collapse event is not canceled, the TreeViewX control collapses the item, and then fires an AfterCollapse event.

AfterDBAddNode

This event is fired after a node is added from the data source.

Syntax

Visual Basic

Private Sub object_BeforeDBAddNode(Node)

Visual C++

OnBeforeDBAddNodeObject(Node);

Delphi

Procedure BeforeDBAddNode(Sender, Node);

The AfterDBAddNode event syntax has these parts:

Part | Description
Node | A Branch object which represents the node just added.

Remarks

TreeViewX is bound to a database by specifying a Data control in the DataSource property at design time using the Properties window or by setting the DataSource property at runtime. A column in the database is bound to a the TreeViewX by using the DataField property of the TreeViewX. See the comments on data binding to the TreeView.

AfterExpand

The AfterExpand event is fired after an item has been expanded (opened).

Syntax

Visual Basic

Private Sub object_AfterExpand(Node)

Visual C++

OnAfterExpandObject(Node);

Delphi

Procedure AfterExpand(Sender, Node);

The AfterExpand event syntax has these parts:

Part | Description
Node | A Branch object that is being expanded.

Remarks

When a node is expanded in the TreeViewX control, the TreeViewX control fires the BeforeExpand event before the node is expanded. The user may cancel the expand event by setting the bProcessed variable to True. If the expand event is not canceled, the TreeViewX control expands the item, and then fires an AfterExpand event.

AfterSelChange

The AfterSelChange event is fired after an item is selected.

Syntax

Visual Basic

Private Sub object_AfterSelChange(Node)

Visual C++

OnAfterSelChangeObject(Node);

Delphi

Procedure AfterSelChange(Sender, Node);

The AfterSelChange event syntax has these parts:

Part | Description
Node | A Branch object that is has been selected.

Remarks

When a node is selected in the TreeViewX control, the TreeViewX control fires the BeforeSelChange event before the selection is made. The user may cancel the selection change by setting the bProcessed variable to True. If the selection change is not canceled, the TreeViewX control selects the item, and then fires an AfterSelChange event.

BeforeCollapse

The BeforeCollapse event is fired before an item is collapsed (closed).

Syntax

Visual Basic

Private Sub object_BeforeCollapse(Node, bProcessed)

Visual C++

OnBeforeCollapseObject(Node, bProcessed);

Delphi

Procedure BeforeCollapse(Sender, Node, bProcessed);

The BeforeCollapse event syntax has these parts:

Part | Description
Node | A Branch object that is being collapsed.
bProcessed | A Boolean expression that specifies whether the event procedure processed the event.

Settings

The settings for bProcessed are:

Setting | Description
True | The TreeViewX control will ignore the collapse event.
False | (Default) The node will be collapsed.

Remarks

When a node is collapsed in the TreeViewX control, the TreeViewX control fires the BeforeCollapse event before the node is collapsed. The user may cancel the collapse event by setting the bProcessed variable to True. If the collapse event is not canceled, the TreeViewX control collapses the item, and then fires an AfterCollapse event.

BeforeDBAddNode

This event is fired prior to a node being added from the data source.

Syntax

Visual Basic

Private Sub object_BeforeDBAddNode(Node, Text, bCancel)

Visual C++

OnBeforeDBAddNodeObject(Node, Text, bCancel);

Delphi

Procedure BeforeDBAddNode(Sender, Node, Text, bCancel);

The BeforeDBAddNode event syntax has these parts:

Part | Description
Node | A Branch object that is the parent of the node being added.
Text | The text of the node being added.
bCancel | A boolean variable that can be used to cancel the addition of the node.

Settings

The settings for bCancel are:

Setting | Description
True | The Branch object will not be added.
False | (Default) The Branch object will be added.

Remarks

TreeViewX is bound to a database by specifying a Data control in the DataSource property at design time using the Properties window or by setting the DataSource property at runtime. A column in the database is bound to a the TreeViewX by using the DataField property of the TreeViewX. See the comments on data binding to the TreeView.

The Text parameter is passed by reference, meaning you can change the value of text before it is added.

BeforeExpand

The BeforeExpand event is fired before an item is expanded (opened).

Syntax

Visual Basic

Private Sub object_BeforeExpand(Node, bProcessed)

Visual C++

OnBeforeExpandObject(Node, bProcessed);

Delphi

Procedure BeforeExpand(Sender, Node, bProcessed);

The BeforeExpand event syntax has these parts:

Part | Description
Node | A Branch object that is being expanded.
bProcessed | A Boolean expression that specifies whether the event procedure processed the event.

Settings

The settings for bProcessed are:

Setting | Description
True | The TreeViewX control will ignore the expand event.
False | (Default) The node will be expanded.

Remarks

When a node is expanded in the TreeViewX control, the TreeViewX control fires the BeforeExpand event before the node is expanded. The user may cancel the expand event by setting the bProcessed variable to True. If the expand event is not canceled, the TreeViewX control expands the item, and then fires an AfterExpand event.

BeforeSelChange

The BeforeSelChange event is fired before an item is selected.

Syntax

Visual Basic

Private Sub object_BeforeSelChange(Node, bProcessed)

Visual C++

OnBeforeSelChangeObject(Node, bProcessed);

Delphi

Procedure BeforeSelChange(Sender, Node, bProcessed);

The BeforeSelChange event syntax has these parts:

Part | Description
Node | A Branch object that is losing the selection.
bProcessed | A Boolean expression that specifies whether the event procedure processed the event.

Settings

The settings for bProcessed are:

Setting | Description
True | The TreeViewX control will ignore the selection change event.
False | (Default) The selection change will be performed.

Remarks

When a node is selected in the TreeViewX control, the TreeViewX control fires the BeforeSelChange event before the selection is made. The user may cancel the selection change by setting the bProcessed variable to True. If the selection change is not canceled, the TreeViewX control selects the item, and then fires an AfterSelChange event.

DeleteItem

The DeleteItem event is fired when an item is about to be deleted.

Syntax

Visual Basic

Private Sub object_DeleteItem(Node)

Visual C++

OnDeleteItemObject(Node);

Delphi

Procedure DeleteItem(Sender, Node);

The DeleteItem event syntax has these parts:

Part | Description
Node | A Branch object that is about to be deleted.

Remarks

You can associate data with each item in the parameter property of a Branch. When the Branch object is about to be deleted, you can free any data structures you have allocated in the DeleteItem Event.

InPlaceEditBegin

The InPlaceEditBegin event is fired before an item is about to be edited by the user.

Syntax

Visual Basic

Private Sub object_InPlaceEditBegin(Node, bAllow)

Visual C++

OnInPlaceEditBeginObject(Node, bAllow);

Delphi

Procedure InPlaceEditBegin(Sender, Node, bAllow);

The InPlaceEditBegin event syntax has these parts:

Part | Description
Node | A Branch object that is being edited.
bAllow | A Boolean expression that specifies if branch is allowed to be edited.

Settings

The settings for bAllow are:

Setting | Description
True | (Default) The TreeViewX control will allow the item to be edited.
False | The TreeViewX control will not allow the item to be edited.

Remarks

When a selected node is single clicked, the TreeViewX control will allow that node to be edited inline.

InPlaceEditEnd

The InPlaceEditEnd event is fired before an item is about to be edited by the user.

Syntax

Visual Basic

Private Sub object_InPlaceEditEnd(Node, Text, fAllow)

Visual C++

OnInPlaceEditEndObject(Node, Text, bAllow);

Delphi

Procedure InPlaceEditEnd(Sender, Node, Text, bAllow);

The InPlaceEditEnd event syntax has these parts:

Part | Description
Node | A Branch object that is being edited.
Text | A string which contains the new text of the item.
bAllow | A Boolean expression that specifies if branch will accept the new value.

Settings

The settings for bAllow are:

Setting | Description
True | (Default) The TreeViewX control will assign the new text to the item.
False | The TreeViewX control will not assign the new text to the item.

Remarks

When a selected node is single clicked, the TreeViewX control will allow that node to be edited inline.

LButtonDblClick

The LButtonDblClick event is fired when the left button of the mouse is double clicked over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_LButtonDblClick(Node, x, y)

Visual C++

OnLButtonDblClickObject(Node, x, y);

Delphi

Procedure LButtonDblClick(Sender, Node, x, y);

The LButtonDblClick event syntax has these parts:

Part | Description
Node | A Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the LButtonDblClick event.
y | A short integer with the y position of the mouse at the time of the LButtonDblClick event.

LButtonDown

The LButtonDown event is fired when the left button of the mouse is pressed over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_LButtonDown(Node, x, y)

Visual C++

OnLButtonDownObject(Node, x, y);

Delphi

Procedure LButtonDown(Sender, Node, x, y);

The LButtonDown event syntax has these parts:

Part | Description
Node | A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the LButtonDown event.
y | A short integer with the y position of the mouse at the time of the LButtonDown event.

LButtonUp

The LButtonUp event is fired when the left button of the mouse is released over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_LButtonUp(Node, x, y)

Visual C++

OnLButtonUpObject(Node, x, y);

Delphi

Procedure LButtonUp(Sender, Node, x, y);

The LButtonUp event syntax has these parts:

Part | Description
Node | A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the LButtonUp event.
y | A short integer with the y position of the mouse at the time of the LButtonUp event.

RButtonDblClick

The RButtonDblClick event is fired when the right button of the mouse is double clicked over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_RButtonDblClick(Node, x, y)

Visual C++

OnRButtonDblClickObject(Node, x, y);

Delphi

Procedure RButtonDblClick(Sender, Node, x, y);

The RButtonDblClick event syntax has these parts:

Part | Description
Node | A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the RButtonDblClick event.
y | A short integer with the y position of the mouse at the time of the RButtonDblClick event.

RButtonDown

The RButtonDown event is fired when the right button of the mouse is pressed over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_RButtonDown(Node, x, y)

Visual C++

OnRButtonDownObject(Node, x, y);

Delphi

Procedure RButtonDown(Sender, Node, x, y);

The LButtonDown event syntax has these parts:

Part | Description
Node | A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the RButtonDown event.
y | A short integer with the y position of the mouse at the time of the RButtonDown event.

RButtonUp

The RButtonUp event is fired when the right button of the mouse is released over the TreeViewX control.

Syntax

Visual Basic

Private Sub object_RButtonUp(Node, x, y)

Visual C++

OnRButtonUpObject(Node, x, y);

Delphi

Procedure RButtonUp(Sender, Node, x, y);

The RButtonUp event syntax has these parts:

Part | Description
Node | A reference to the Branch object that is under the mouse. This will be an empty Branch object if no item is under the mouse.
x | A short integer with the x position of the mouse at the time of the RButtonUp event.
y | A short integer with the y position of the mouse at the time of the RButtonUp event.

Remarks for TreeViewX Images

At design time, you can transfer a graphic with the Clipboard using the Copy, Cut, and Paste commands on the Edit menu. At run time, you can use Clipboard methods such as GetData, SetData, and GetFormat with the nontext Clipboard constants vbCFBitmap, vbCFMetafile, and vbCFDIB, which are listed in the Visual Basic (VB) object library in the Object Browser.

When setting a picture property at design time, the graphic is saved and loaded with the form. If you create an executable file, the file contains the image.

Note At run time, a picture property can be set to any other object's Picture property, or you can assign it the graphic returned by the LoadPicture function.

The TreeViewX control only supports bitmap images in a picture property.

For the image to display, the EnableBitmaps Property must be set to TRUE. The way in which a custom bitmap is interpreted depends on the value of the UseStateBitmaps Property.

When a custom bitmap is assigned to an item, the TreeViewX control can interpret the bitmap as a normal or state formatted bitmap. A normal bitmap is displayed in it’s entirety next to the item. The interpretation of custom bitmaps depends on the setting of the UseStateBitmaps Property.

The picture to be displayed depends on a number of other settings. The picture displayed next to an item depends on the following rules:

CustomItemPicture Property

This picture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardItemPicture Property

If the CustomItemPicture property is set to None, then the StandardItemPicture property specifies the picture that will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomLevelPicture Property

If both the CustomItemPicture and StandardItemPicture are set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the CustomLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

StandardLevelPicture Property

If the CustomItemPicture, StandardItemPicture, and the CustomLevelPicture for the level on which this item resides are all set to None, then the picture displayed next to the item will depend on this setting. If not set to None for the level on which the item resides, the StandardLevelPicture will be displayed next to the item. If not set to None, this setting overrides all following properties.

CustomDefaultPicture Property

If all of the above properties are set to None, then the picture displayed next to the item will depend on this setting. If not set to None, the CustomDefaultPicture will be displayed next to the item. If not set to None, this setting overrides the StandardDefaultPicture.

StandardDefaultPicture Property

This is the default picture that will be displayed next to an item. This property is always set to a picture and can never be set to None. If all the above properties are set to None, then this will be the picture that will be displayed next to the item.


Common Properties, Methods and Events

This appendix contains the reference for all the properties and methods common to most of the ProtoView Controls and ActiveX controls in general. Each property and method will list exactly which controls support that method.

Common Properties

Introduction

Many properties are common to most or all the ProtoView Controls, and are common to most ActiveX controls in general. Rather than list the details of these methods for each control, these common properties have been collected in a single reference area. Note not every ProtoView Control will support all the properties listed here.

Appearance

Returns or sets the paint style of a ProtoView Control object. Read only at run time.

Syntax

Visual Basic

object.Appearance = value
value = object.Appearance

Visual C++

object.SetAppearance(value);
value = object.GetAppearance( );

Delphi

object.Appearance := value;
value := object.Appearance;

The Appearance property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
value | A numeric expression that evaluates to an appearance style for a ProtoView Control.

Settings

The settings for value are:

Setting | Description
0 | Flat. Paints controls and forms with without visual effects.
1 | (Default) 3D. Paints controls with three-dimensional effects.

Remarks

If set to 1 at design time, the Appearance property draws the control with three-dimensional effects. Setting the Appearance property to 1 also disables the BorderStyle property.

BackColor

BackColor returns or sets the background color of a ProtoView Control object.

Syntax

Visual Basic

object.BackColor = color
color = object.BackColor

Visual C++

object.SetBackColor(color);
color = object.GetBackColor( );

Delphi

object.BackColor:= color;
color:= object.BackColor;

The BackColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
color | A value or constant that determines the background color of an object, as described in Notes About Colors.

Settings

See the section Notes About Colors in this chapter.

Remarks

See the section Notes About Colors in this chapter

BorderStyle

Returns or sets the border style for a ProtoView Control object, read only at run time.

Syntax

Visual Basic

object.BorderStyle = value
value = object.BorderStyle

Visual C++

object.SetBorderStyle(value);
value = object.GetBorderStyle( );

Delphi

object.BorderStyle:= value;
value:= object.BorderStyle;

The BorderStyle property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
value | A numeric expression that evaluates to a border style for a ProtoView Control.

Settings

The settings for value are:

Setting | Description
0 | (Default) None.
1 | Fixed Single.

Remarks

The BorderStyle property is not active unless the Appearance property is set to 0.

Enabled

Returns or sets a value that determines whether a ProtoView Control object can respond to user-generated events.

Syntax

Visual Basic

object.Enabled = boolean
boolean = object.Enabled

Visual C++

object.SetEnabled(boolean);
boolean = object.GetEnabled( );

Delphi

object.Enabled:= boolean;
boolean:= object.Enabled;

The Enabled property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
boolean | A Boolean expression that specifies whether object can respond to user-generated events.

Settings

The settings for boolean are:

Setting | Description
True | (Default) Allows object to respond to events.
False | Prevents object from responding to events.

Remarks

The Enabled property allows forms and controls to be enabled or disabled at run time. For example, you can disable objects that don't apply to the current state of the application. You can also disable a control used purely for display purposes, such as a text box that provides read-only information.

Font

Returns a Font object.

Syntax

Visual Basic

object.Font = font
font = object.Font

Visual C++

object.SetFont(font);
font = object.GetFont( );

Delphi

object.Font:= font;
font:= object.Font;

The Font property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
font | A font object which describes the controls font characteristics.

Remarks

Use the Font property of an object to identify a specific Font object whose properties you want to use. For example, the following code changes the Bold property setting of a Font object identified by the Font property of a TextBox object:

Visual Basic Example

txtFirstName.Font.Bold = True

Visual C++ Example

pIOleFont->SetBold(TRUE);
txtFirstName.SetFont(pIOleFont);

ForeColor

ForeColor returns or sets the foreground color used to display text and graphics in to a ProtoView Control object.

Syntax

Visual Basic

object.ForeColor = color
color = object.ForeColor

Visual C++

object.SetForeColor(color);
color = object.GetForeColor( );

Delphi

object.ForeColor:= color;
color:= object.ForeColor;

The ForeColor property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
color | A value or constant that determines the foreground color of an object, as described in Notes About Colors.

Settings

See the section Notes About Colors in this chapter.

Remarks

See the section Notes About Colors in this chapter.

GetCaretPosition

This method returns the zero-based index of the caret within the text of an editable component.

Syntax

Visual Basic

ReturnValue = object.GetCaretPosition

C++

ReturnValue = object.GetCaretPosition ( );

Delphi

ReturnValue := object.GetCaretPosition()

The GetCaretPosition method syntax has these parts:

Part

 Description

object

 An object expression that evaluates to a ProtoView Control.

ReturnValue

 A short integer value.

GetEndSelection

This method returns the zero-based index of the last selected character within the text of an editable component.

Syntax

Visual Basic

ReturnValue = object.GetEndSelection

C++

ReturnValue = object.GetEndSelection ( );

Delphi

ReturnValue := object.GetEndSelection()

The GetEndSelection method syntax has these parts:

Part

 Description

object

 An object expression that evaluates to a ProtoView Control.

ReturnValue

 A short integer value.

GetStartSelection

This method returns the zero-based index of the first selected character within the text of an editable component.

Syntax

Visual Basic

ReturnValue = object.GetStartSelection

C++

ReturnValue = object.GetStartSelection ( );

Delphi

ReturnValue := object.GetStartSelection()

The GetStartSelection method syntax has these parts:

Part

 Description

object

 An object expression that evaluates to a ProtoView Control.

ReturnValue

 A short integer value.

hWnd

Returns a handle to a ProtoView Control object. Read-only at run time, not available at design time.

Syntax

Visual Basic

hWnd = object.hWnd

Visual C++

hWnd = object.GethWnd( );

Delphi

hWnd:= object.hWnd;

The hWnd property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
hWnd | A handle which contains the windows handle of the object.

Remarks

The Microsoft Windows operating environment identifies each form and control in an application by assigning it a handle, or hWnd. The hWnd property is used with Windows API calls. Many Windows operating environment functions require the hWnd of the active window as an argument.

Note Because the value of this property can change while a program is running, never store the hWnd value in a variable.

ValidateLimit

Returns or sets how strict a control will enforce upper and lower limits.

Syntax

Visual Basic

object.ValidateLimit = value
value = object.ValidateLimit

Visual C++

object.SetValidateLimit(value);
value = object.GetValidateLimit( );

Delphi

object.ValidateLimit:= value;
value:= object.ValidateLimit;

The ValidateLimit property syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
value | A numeric expression that evaluates to a validation criteria for a ProtoView Control.

Settings

The settings for value are:

Setting | Description
0 | (Default) The component will validate the upper and lower limits before each keystroke.
1 | The component will validate the upper and lower limits only when focus has been lost.

Remarks

If the component validates the upper and lower limits before each keystroke, the control will beep and prevent entry of a value that will violate the limit. For example, if you have 10000 as an upper limit and the control is currently displaying 9000, the control will prevent the addition of a fifth digit. If you set a lower limit 10 or above, then you will be unable to hightlight the controls contents and enter a new value, since any digit entered will be less than 10.

Notes about Colors

Visual Basic uses the Microsoft Windows operating environment red-green-blue (RGB) color scheme. The settings for color are:

Setting | Description
Normal RGB colors | Colors specified by using the Color palette or by using the RGB or QBColor functions in code.
System default colors | Colors specified by system color constants listed in the Visual Basic (VB) object library in the Object Browser. The Windows operating environment substitutes the user's choices as specified in the Control Panel settings.

For all forms and controls, the default settings at design time are:

BackColor set to the system default color specified by the constant vbWindowBackground.

ForeColor set to the system default color specified by the constant vbWindowText.

The valid range for a normal RGB color is 0 to 16,777,215 (&HFFFFFF). The high byte of a number in this range equals 0; the lower 3 bytes, from least to most significant byte, determine the amount of red, green, and blue, respectively. The red, green, and blue components are each represented by a number between 0 and 255 (&HFF). If the high byte isn't 0, Visual Basic uses the system colors, as defined in the user's the Control Panel settings and by constants listed in the Visual Basic (VB) object library in the Object Browser.

To display text in the Windows operating environment, both the text color must be solid. If the text color you've selected isn’t displayed, the selected colors may be dithered, that is, comprised of up to three different-colored pixels. If you choose a dithered color for the text, the nearest solid color will be substituted.

Common Methods

Introduction

Many methods are common to most or all the ProtoView Controls, and are common to most ActiveX controls in general. Rather than list the details of these methods for each control, these common properties have been collected in a single reference area. Note not every ProtoView Control will support all the methods listed here.

AboutBox

Use the AboutBox command to find the version number and other pertinent information about WinX.

Syntax

Visual Basic

object.AboutBox

Visual C++

object. AboutBox();

Delphi

object. AboutBox;

The AboutBox method syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.

Common Events

Introduction

Many events are common to most or all the ProtoView Controls, and are common to most ActiveX controls in general. Rather than list the details of these events for each control, these common events have been collected in a single reference area. Note not every ProtoView Control will support all the events listed here.

Click

Occurs when the user presses and then releases a mouse button a ProtoView Control object. It can also occur when the value of a ProtoView Control object is changed.

Syntax

Visual Basic

Private Sub Object_Click([index As Integer])

Visual C++

void OnClickObject();

Delphi

Procedure Click(Sender : TObject)

The Click event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

For a control, this event occurs when the user:

Clicks a control with the left or right mouse button. With a 3D check box, 3D command button, or 3D option button control, the Click event occurs only when the user clicks the left mouse button.

Presses the SPACEBAR when a 3D command button, 3D option button, or 3D check box control has the focus.

Presses ENTER when a form has a 3D command button control with its Default property set to True.

Presses ESC when a form has a Cancel buttonfor example, a 3D command button control with its Cancel property set to True.

Presses an access key for a control. For example, if the caption of a 3D command button control is "&Go", pressing ALT+G triggers the event.

Typically, you attach a Click event procedure to a 3D command button control to carry out commands and command-like actions. For the other applicable controls, use this event to trigger actions in response to a change in the control.

Note To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

DblClick

Occurs when the user presses and releases a mouse twice quickly over a ProtoView Control object.

Syntax

Visual Basic

Private Sub Object_DblClick([index As Integer])

Visual C++

void OnDblClickObject();

Delphi

Procedure DblClick(Sender : TObject)

The DblClick event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.

Remarks

The argument Index uniquely identifies a control if it's in a control array. You can use a DblClick event procedure for an implied action, such as double-clicking an icon to open a window or document. You can also use this type of procedure to carry out multiple steps with a single action, such as double-clicking to select an item in a list box and to close the dialog box.

For those objects that receive Mouse events, the events occur in this order: MouseDown, Click, MouseUp, and DblClick.

If DblClick doesn't occur within the system's double-click time limit, the object recognizes another Click event. The double-click time limit may vary because the user can set the double-click speed in the Control Panel. When you're attaching procedures for these related events, be sure that their actions don't conflict.

Note To distinguish between the left, right, and middle mouse buttons, use the MouseDown and MouseUp events.

KeyDown

Fired each time a key is pressed when a ProtoView Control object has input focus.

Syntax

Visual Basic

Private Sub Object_KeyDown([index As Integer], KeyCode As Integer, Shift As Integer)

Visual C++

void OnKeyDownObject(short KeyCode, short Shift);

Delphi

Procedure KeyDown(Sender : TObject, KeyCode : Integer, Shift : Integer)

The KeyDown event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
KeyCode | A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the constants in the object library in the Object Browser.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Remarks

The object with the focus receives all keystrokes. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

Extended character keys such as function keys.

Navigation keys.

Combinations of keys with standard keyboard modifiers.

Distinguishing between the numeric keypad and regular number keys.

Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

The ENTER key if the form has a 3D command button control with the Default property set to True.

The ESC key if the form has a 3D command button control with the Cancel property set to True.

The TAB key.

KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the Shift argument, you can declare constants that define the bits within the argument by using constants listed in the object library in the Object Browser. The shift constants have the following values:

Constant | Value
vbShiftMask | 1
vbCtrlMask | 2
vbAltMask | 4

The constants act as bit masks that you can use to test for any combination of keys. Place the constants at the procedure level or in the Declarations section of a module and use this syntax:

Const constantname = expression

You test for a condition by first assigning each result to a temporary integer variable and then comparing Shift to a bit mask. Use the And operator with the Shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, for example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, for example:

If ShiftDown And CtrlDown Then

Note If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events. Use the KeyPreview property to create global keyboard-handling routines.

KeyPress

Fired each time a key is pressed when a ProtoView Control object has input focus.

Syntax

Visual Basic

Private Sub Object_KeyPress([index As Integer], KeyAscii As Integer)

Visual C++

void OnKeyPressObject(short FAR* KeyAscii);

Delphi

Procedure KeyPress(Sender : TObject, var KeyAscii: Integer)

The KeyPress event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
KeyAscii | An integer that returns a standard numeric ANSI keycode. The KeyAscii argument is passed by reference; changing it sends a different character to the object. Changing KeyAscii to 0 cancels the keystroke so the object receives no character.

Remarks

The object with the focus receives the event. A form can receive the event only if it has no visible and enabled controls or if the KeyPreview property is set to True. A KeyPress event can involve any printable keyboard character, the CTRL key combined with a character from the standard alphabet or one of a few special characters, and the ENTER or BACKSPACE key. Changing the value of the KeyAscii argument changes the character displayed.

You can convert the KeyAscii argument into a character by using the expression:

Chr(KeyAscii)

You can then perform string operations and translate the character back to an ANSI number that the control can interpret by using the expression:

KeyAscii = Asc(char)

Use KeyDown and KeyUp event procedures to handle any keystroke not recognized by KeyPress, such as function keys, editing keys, navigation keys, and any combinations of these with keyboard modifiers. Unlike the KeyDown and KeyUp events, KeyPress doesn't indicate the physical state of the keyboard; instead, it passes a character.

KeyPress interprets the uppercase and lowercase of each character as separate key codes and, therefore, as two separate characters. KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: keycode, which indicates the physical key (thus returning A and a as the same key), and shift, which indicates the state of shift+key and therefore returns either A or a.

If the KeyPreview property is set to True, a form receives the event before controls on the form receive the event. Use the KeyPreview property to create global keyboard-handling routines.

Note The ANSI number for the keyboard combination of CTRL+@ is 0. Because Visual Basic recognizes a KeyAscii value of 0 as a zero-length string (""), avoid using CTRL+@ in your applications.

KeyUp

Fired each time a key is released when a ProtoView Control object has input focus.

Syntax

Visual Basic

Private Sub Object_KeyUp([index As Integer], KeyCode As Integer, Shift As Integer)

Visual C++

void OnKeyUpObject(short KeyCode, short Shift);

Delphi

Procedure KeyUp(Sender : TObject, KeyCode : Integer, Shift : Integer)

The KeyUp event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
KeyCode | A key code, such as vbKeyF1 (the F1 key) or vbKeyHome (the HOME key). To specify key codes, use the constants in the object library in the Object Browser.
Shift | An integer that corresponds to the state of the SHIFT, CTRL, and ALT keys at the time of the event. The Shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT are pressed, the value of Shift is 6.

Remarks

The object with the focus receives all keystrokes. Although the KeyDown and KeyUp events can apply to most keys, they're most often used for:

Extended character keys such as function keys.

Navigation keys.

Combinations of keys with standard keyboard modifiers.

Distinguishing between the numeric keypad and regular number keys.

Use KeyDown and KeyUp event procedures if you need to respond to both the pressing and releasing of a key.

KeyDown and KeyUp aren't invoked for:

The ENTER key if the form has a 3D command button control with the Default property set to True.

The ESC key if the form has a 3D command button control with the Cancel property set to True.

The TAB key.

KeyDown and KeyUp interpret the uppercase and lowercase of each character by means of two arguments: KeyCode, which indicates the physical key (thus returning A and a as the same key) and Shift, which indicates the state of shift+key and therefore returns either A or a.

If you need to test for the Shift argument, you can declare constants that define the bits within the argument by using constants listed in the object library in the Object Browser. The shift constants have the following values:

Constant | Value
vbShiftMask | 1
vbCtrlMask | 2
vbAltMask | 4

The constants act as bit masks that you can use to test for any combination of keys. Place the constants at the procedure level or in the Declarations section of a module and use this syntax:

Const constantname = expression

You test for a condition by first assigning each result to a temporary integer variable and then comparing Shift to a bit mask. Use the And operator with the Shift argument to test whether the condition is greater than 0, indicating that the modifier was pressed, for example:

ShiftDown = (Shift And vbShiftMask) > 0

In a procedure, you can test for any combination of conditions, for example:

If ShiftDown And CtrlDown Then

Note If the KeyPreview property is set to True, a form receives these events before controls on the form receive the events. Use the KeyPreview property to create global keyboard-handling routines.

MouseDown

Occurs when the user presses (MouseDown) or releases (MouseUp) a mouse button over a ProtoView Control object.

Syntax

Visual Basic

Private Sub Object_MouseDown([index As Integer], Button As Integer, Shift As Integer, x As Single, y As Single)

Visual C++

void OnMouseDownObject(short Button, short Shift, long x, long y);

Delphi

Procedure MouseDown(Sender : TObject, Button : Integer, Shift : Integer, x : Single, y : Single)

The MouseDown event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
Button | Returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The Button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the Button argument is pressed or released. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The Shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.
x, y | Returns a number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Remarks

Use a MouseDown or MouseUp event procedure to specify actions that will occur when a given mouse button is pressed or released. Unlike the Click and DblClick events, MouseDown and MouseUp events enable you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keyboard modifiers.

The following applies to both Click and DblClick events:

If a mouse button is pressed while the pointer is over a control, that object "captures" the mouse and receives all mouse events up to and including the last MouseUp event. This implies that the x, y mouse-pointer coordinates returned by a mouse event may not always be in the client area of the object that receives them.

If mouse buttons are pressed in succession, the object that captures the mouse after the first press receives all mouse events until all buttons are released.

If you need to test for the button or shift arguments, you can use constants listed in the object library in the Object Browser to define the bits within the argument:

Constant | Value | Description
vbLeftButton | 1 | Left button is pressed.
vbRightButton | 2 | Right button is pressed.
vbMiddleButton | 4 | Middle button is pressed.
vbShiftMask | 1 | Middle button is pressed.
vbCtrlMask | 2 | SHIFT key is pressed.
vbAltMask | 4 | ALT key is pressed.

The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.

MouseMove

Occurs when the user moves the mouse over a ProtoView Control object.

Syntax

Visual Basic

Private Sub Object_MouseMove([index As Integer], Button As Integer, Shift As Integer, x As Single, y As Single)

Visual C++

void OnMouseMoveObject(short Button, short Shift, long x, long y);

Delphi

Procedure MouseMove(Sender : TObject, Button : Integer, Shift : Integer, x : Single, y : Single)

The MouseMove event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
Button | Returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The Button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the Button argument is pressed or released. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The Shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.
x, y | Returns a number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Remarks

The MouseMove event is generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes a MouseMove event whenever the mouse position is within its borders.

If you need to test for the button or shift arguments, you can use constants listed in the object library in the Object Browser to define the bits within the argument:

Constant | Value | Description
vbLeftButton | 1 | Left button is pressed.
vbRightButton | 2 | Right button is pressed.
vbMiddleButton | 4 | Middle button is pressed.
vbShiftMask | 1 | Middle button is pressed.
vbCtrlMask | 2 | SHIFT key is pressed.
vbAltMask | 4 | ALT key is pressed.

The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.

You test for a condition by first assigning each result to a temporary integer variable and then comparing the button or shift arguments to a bit mask. Use the And operator with each argument to test if the condition is greater than zero, indicating the key or button is pressed, as in the following code:

LeftDown = (Button And vbLeftButton) > 0

CtrlDown = (Shift And vbCtrlMask) > 0

Then, in a procedure, you can test for any combination of conditions, as follows:

If LeftDown And CtrlDown Then

Note You can use MouseDown and MouseUp event procedures to respond to events caused by pressing and releasing mouse buttons.

The button argument for MouseMove differs from the button argument for MouseDown and MouseUp. For MouseMove, the button argument indicates the current state of all buttons; a single MouseMove event can indicate that some, all, or no buttons are pressed. For MouseDown and MouseUp, the button argument indicates exactly one button per event.

Any time you move a window inside a MouseMove event, it can cause a cascading event. MouseMove events are generated when the window moves underneath the pointer. A MouseMove event can be generated even if the mouse is perfectly stationary.

MouseUp

Occur when the user presses and releases a mouse button over a ProtoView Control object.

Syntax

Visual Basic

Private Sub Object_MouseUp([index As Integer], Button As Integer, Shift As Integer, x As Single, y As Single)

Visual C++

void OnMouseUpObject(short Button, short Shift, long x, long y);

Delphi

Procedure MouseUp(Sender : TObject, Button : Integer, Shift : Integer, x : Single, y : Single)

The MouseUp event syntax has these parts:

Part | Description
object | An object expression that evaluates to a ProtoView Control.
index | An integer that uniquely identifies a control if it's in a control array.
Button | Returns an integer that identifies the button that was pressed (MouseDown) or released (MouseUp) to cause the event. The Button argument is a bit field with bits corresponding to the left button (bit 0), right button (bit 1), and middle button (bit 2). These bits correspond to the values 1, 2, and 4, respectively. Only one of the bits is set, indicating the button that caused the event.
Shift | Returns an integer that corresponds to the state of the SHIFT, CTRL, and ALT keys when the button specified in the Button argument is pressed or released. A bit is set if the key is down. The shift argument is a bit field with the least-significant bits corresponding to the SHIFT key (bit 0), the CTRL key (bit 1), and the ALT key (bit 2 ). These bits correspond to the values 1, 2, and 4, respectively. The Shift argument indicates the state of these keys. Some, all, or none of the bits can be set, indicating that some, all, or none of the keys are pressed. For example, if both CTRL and ALT were pressed, the value of shift would be 6.
x, y | Returns a number that specifies the current location of the mouse pointer. The x and y values are always expressed in terms of the coordinate system set by the ScaleHeight, ScaleWidth, ScaleLeft, and ScaleTop properties of the object.

Remarks

Use a MouseDown or MouseUp event procedure to specify actions that will occur when a given mouse button is pressed or released. Unlike the Click and DblClick events, MouseDown and MouseUp events enable you to distinguish between the left, right, and middle mouse buttons. You can also write code for mouse-keyboard combinations that use the SHIFT, CTRL, and ALT keyboard modifiers.

The following applies to both Click and DblClick events:

If a mouse button is pressed while the pointer is over a control, that object "captures" the mouse and receives all mouse events up to and including the last MouseUp event. This implies that the x, y mouse-pointer coordinates returned by a mouse event may not always be in the client area of the object that receives them.

If mouse buttons are pressed in succession, the object that captures the mouse after the first press receives all mouse events until all buttons are released.

If you need to test for the button or shift arguments, you can use constants listed in the object library in the Object Browser to define the bits within the argument:

Constant | Value | Description
vbLeftButton | 1 | Left button is pressed.
vbRightButton | 2 | Right button is pressed.
vbMiddleButton | 4 | Middle button is pressed.
vbShiftMask | 1 | Middle button is pressed.
vbCtrlMask | 2 | SHIFT key is pressed.
vbAltMask | 4 | ALT key is pressed.

The constants then act as bit masks you can use to test for any combination of buttons without having to figure out the unique bit field value for each combination.


TreeView Branch Object

TreeViewX Branch Object

A Branch object represents a single item and all its children (if any) in a TreeViewX control. You may manipulate an item through the methods and properties of a Branch object and you may add or remove child items through Branch object methods.

To add items to the TreeViewX control, use the Branches property to obtain the main Branch object, then use the Add method of the Branch object to add items to the list. Likewise, you can use the Remove method of the Branch object to remove items from the list. Most operations that affect the list of items in a TreeViewX control are done through the methods and properties of the Branch object.

TreeViewX Branch Properties

List of Properties

The ProtoView TreeViewX Branch object supports the following properties:

CustomItemPicture

Data

IsOpen

Level

StandardItemPicture

Text

CustomItemPicture

The CustomItemPicture property sets or returns the default picture displayed next to an item on the TreeViewX control.

Syntax

Visual Basic

object.CustomItemPicture = picture
picture = object.CustomItemPicture

Visual C++

object.SetCustomItemPicture(picture);
picture = object.GetCustomItemPicture( );

Delphi

object.CustomItemPicture := picture;
picture:= object.CustomItemPicture;

The CustomItemPicture property syntax has these parts:

Part | Description
object | A Branch object.
picture | A picture object which contains a graphic to assign as described in Settings.

Settings

The settings for picture are:

Setting | Description
(None) | (Default) No picture.
(Bitmap, icon, metafile) | Specifies a graphic. You can load the graphic from the Properties window at design time. At run time, you can also set this property using the LoadPicture function on a bitmap, icon, or metafile.

Remarks

Please see the Remarks for TreeViewX images.

Data

The Data property is a user defined value that can be kept with each item in a TreeViewX control. Not available at design time.

Syntax

Visual Basic

object.Data = value
value = object.Data

Visual C++

object.SetData(value);
value = object.GetData( );

Delphi

object.Data:= value;
value:= object.Data;

The Data property syntax has these parts:

Part | Description
object | A Branch object.
value | A long integer specified by the user as a value or a pointer to data. It is stored with the Branch object in the TreeViewX control.

Remarks

The Data property is user defined. Neither the TreeViewX control nor the Branch object use this value. You can use the Data property to associate a number (or a pointer to a data structure for languages that allow the storage and usage of pointers) with a TreeViewX control item.

Note: You cannot set the Data property on the main Branch. The main Branches Data property is always set to zero.

IsOpen

The IsOpen property returns a boolean value indicating whether or not the Branch object is open. Read only at run time, not available at design time.

Syntax

Visual Basic

boolean = object.IsOpen

Visual C++

boolean = object.GetIsOpen( );

Delphi

boolean := object.IsOpen;

Part | Description
object | A Branch object.
boolean | A Boolean expressionK which returns whether the Branch object is open.

Settings

The settings for boolean are:

Setting | Description
True | The object is open.
False | The object is closed.

Remarks

Branch objects that are not visible are automatically closed.

Note: The IsOpen property on the main Branch is meaningless. The main Branches IsOpen property is always returns True.

Level

The Level property indicates the level the Branch object is on in a TreeViewX control. Read only at run time, not available at design time.

Syntax

Visual Basic

object.Level = value
value = object.Level

Visual C++

object.SetLevel(value);
value = object.GetLevel( );

Delphi

object.Level:= value;
lue:= object.Level;

Part | Description
object | A Branch object.
value | A short integer which returns the level the Branch item is located on.

Remarks

The Level property represents the hierarchical level on which the Branch object resides. A Branch object at the root leve (topmost level) will have its Level property set to 0. A child of a root item will have a Level property of 1, and so on.

Note: The Level property on the main Branch is meaningless. The main Branches Level property is always set to zero.

StandardItemPicture

Returns or sets a value indicating the default picture that will be displayed next to a specific item in the TreeViewX control.

Syntax

Visual Basic

object. StandardItemPicture = value
value = object. StandardItemPicture

Visual C++

object.SetStandardItemPicture(value);
value = object.GetStandardItemPicture( );

Delphi

object. StandardItemPicture := value;
value:= object. StandardItemPicture;

The StandardItemPicture property syntax has these parts:

Part | Description
object | A Branch object.
value | A constant that determines the default picture that will be displayed next to an item in the TreeViewX control, as described in Settings.

Settings

The settings for value are:

Setting | Description
pvtNone | No picture.
pvtpicFolders | (Default) Folder Picture.
pvtpicBoxes1 | Boxes #1 Picture.
pvtpicDocument | Document Picture.
pvtpicHardDisk | Hard Disk Picture.
pvtpicProgram | Program File Picture.
pvtpicSystemFile | System File Picture.
pvtpicBoxes2 | Boxes #2 Picture.
pvtpicBoxes3 | Boxes #3 Picture.
pvtpicASCIIFile | ASCII File Picture.
pvtpicHelpFile | Help File Picture.

Remarks

Please see the Remarks for TreeViewX images.

Text

The Text property represents the text string associated with the Branch object. Not available at design time.

Syntax

Visual Basic

object.Text = string
string = object.Text

Visual C++

object.SetText(string);
string = object.GetText( );

Delphi

object.Text:= string;
string:= object.Text;

The Text property syntax has these parts:

Part | Description
object | A Branch object.
string | A string specifying the text that is to be associated with the Branch object.

Remarks

The value of the Text property is initially set in the Add Method. Although you can change the value of the Text property at run time, the placement of the Branch object does not change in the hierarchy even when the Sort Propertyn is set to True. That is to say, the item is not re-sorted in the list.

Note: The Text property on the main Branch is meaningless. The main Branches Text property is always set to a zero length (empty) string.

TreeViewX Branch Methods

List of Methods

The ProtoView TreeViewX Branch object supports the following methods:

Add

Clear

Close

Get

GetHandle

IsLocked

IsMainBranch

IsValid

Lock

Open

Remove

Select

Unlock

Add

Adds a new item to the Branch.

Syntax

Visual Basic

object.Add relation, relative, text

Visual C++

object.Add (relation, relative, text);

Delphi

object.Add (relation, relative, text);

The Add method syntax has these parts:

Part | Description
object | A Branch object.
relationship | A constant that specifies how the new item will be inserted into the list.
relative | A numeric expression constant that specifies the relative item. This argument is a zero based index of the child items of the Branch object. The first child of a Branch is at index 0, the second at index 1, and so on.
text | A string expression that specifies the text of the new item.

Settings

The settings for relationship are:

Setting | Description
pvtPositionInOrder | If the Sort Property is set to True, PositionInOrder causes the new item to be inserted in sorted order in the list. If the Sort Property is set to False, the new item will be inserted at the end of the list. The relative argument is ignored if PositionInOrder is used.
pvtPositionBefore | Causes the new item to appear before the item specified in relative.
pvtPositionAfter | Causes the new item to appear after the item specified in relative.

Remarks

To remove an item from a Branch, use the remove method.

Visual Basic Example

This example adds a number of items to a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Add (mnuAdd). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuAdd_Click()
Dim root As Branch
Dim ParentNode As Branch
Dim ChildNode As Branch

Set root = PTreeView1.Branches

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5")

Set ParentNode = root.Add(PositionInOrder, 0, "Parent Node 3")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 5")
End Sub

Visual C++ Example

This example adds a number of items to a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object in your project.

BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();

CBranch root(m_treeview.GetBranches());

AddParent(root, "Parent 1");
AddParent(root, "Parent 2");
AddParent(root, "Parent 3");
AddParent(root, "Parent 4");
AddParent(root, "Parent 5");

return TRUE;
}

void CMyDialog::AddParent(CBranch& root, LPCTSTR szText)
{
CBranch aParent(root.Add(CBranch::pvtPositionInOrder, 0, szText));

AddChild(aParent, "Child 1");
AddChild(aParent, "Child 2");
AddChild(aParent, "Child 3");
AddChild(aParent, "Child 4");
AddChild(aParent, "Child 5");
}

void CMyDialog::AddChild(CBranch& aParent, LPCTSTR szText)
{
CBranch aChild(aParent.Add(CBranch::pvtPositionInOrder, 0, szText));

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 1");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 2");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 3");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 4");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 5");
}

Clear

Removes all the child items from a Branch.

Syntax

Visual Basic

object.Clear

Visual C++

object.Clear ( );

Delphi

object.Clear;

The Clear method syntax has these parts:

Part | Description
object | A Branch object.

Remarks

If the object is the main Branch, then the TreeViewX control will be cleared of all items. Otherwise, only the children of the specified Branch will be cleared.

Visual Basic Example

This example clears a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Add (mnuAdd) and another that contains the command Clear(mnuClear). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuAdd_Click ()
Dim root As Branch
Dim ParentNode As Branch
Dim ChildNode As Branch

Set root = PTreeView1.Branches
root.Clear

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 1")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionInOrder, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 2")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionAfter, 0, "Child Node 5")

Set ParentNode = root.Add(pvtPositionInOrder, 0, "Parent Node 3")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 1")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 2")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 3")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 4")
Set ChildNode = ParentNode.Add(pvtPositionBefore, 0, "Child Node 5")
End Sub

Private Sub mnuClear_Click ()
Dim root As Branch

Set root = PTreeView1.Branches
root.Clear
End Sub

Visual C++ Example

This example clears a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object in your project. Add a button on the dialog that invokes the OnClear method when pressed.

BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();

CBranch root(m_treeview.GetBranches());

root.Clear();

AddParent(root, "Parent 1");
AddParent(root, "Parent 2");
AddParent(root, "Parent 3");
AddParent(root, "Parent 4");
AddParent(root, "Parent 5");

return TRUE;
}

void CMyDialog::AddParent(CBranch& root, LPCTSTR szText)
{
CBranch aParent(root.Add(CBranch::pvtPositionInOrder, 0, szText));

AddChild(aParent, "Child 1");
AddChild(aParent, "Child 2");
AddChild(aParent, "Child 3");
AddChild(aParent, "Child 4");
AddChild(aParent, "Child 5");
}

void CMyDialog::AddChild(CBranch& aParent, LPCTSTR szText)
{
CBranch aChild(aParent.Add(CBranch::pvtPositionInOrder, 0, szText));

aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 1");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 2");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 3");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 4");
aChild.Add(CBranch::pvtPositionInOrder, 0, "GrandChild 5");
}

void CMyDialog::OnClear()
{
CBranch root(m_treeview.GetBranches());

root.Clear();
}

Close

Closes the Branch object according to command argument.

Syntax

Visual Basic

object.Close command

Visual C++

object.Close ( command );

Delphi

object.Close ( command );

The Close method syntax has these parts:

Part | Description
object | A Branch object.
command | A value or constant that specifies how the Close method will operate on the Branch object.

Settings

The settings for command are:

Setting | Description
Node | Causes the Branch object to close if it is not already closed.
Children | Causes all the children of the Branch object to close.

Remarks

When a Branch is locked, it retains its display state (either open or closed).

Visual Basic Example

This example closes the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Close (mnuClose). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuClose_Click()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

node.Close(pvtNode)
End Sub

Visual C++ Example

This example closes the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnClose method when pressed.

void MyDialog::OnClose()
{
CBranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

node.Close(CBranch::pvtNode)
}

Get

Returns a Branch object from a related Branch object.

Syntax

Visual Basic

object.Get relationship, relative

Visual C++

object.Get ( relationship, relative );

Delphi

object.Get ( relationship, relative );

The Get method syntax has these parts:

Part | Description
object | A Branch object.
relationship | A constant that specifies which new item will be obtained from the list.
relative | A short integer that specifies the relative item. This argument is a zero based index of the child items of the Branch object. The first child of a Branch is at index 0, the second at index 1, and so on.

Settings

The settings for relationship are:

pvtGetNextSibling

Returns the next Branch object that is at the same hierarchical level in the TreeViewX control as this Branch. If no subsequent Branch object exists at this level, the method returns an empty Branch object.

The relative argument is ignored if GetNextSibling is used.

pvtGetPrevSibling

Returns the previous Branch object that is at the same hierarchical level in the TreeViewX control as this Branch. If no previous Branch object exists at this level, the method returns an empty Branch object.

The relative argument is ignored if GetPrevSibling is used.

pvtGetNextVisible

Returns the next Branch object that is visible on the TreeViewX control after this object. If no subsequent Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetNextVisible is used.

pvtGetPrevVisible

Returns the previous Branch object that is visible on the TreeViewX control before this object. If no previous Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevVisible is used.

pvtGetNextSelected

Returns the next Branch object that is selected on the TreeViewX control after this object. If no subsequent selected Branch object exists, the method returns an empty Branch objectK.

The relative argument is ignored if GetNextSelected is used.

pvtGetPrevSelected

Returns the previous Branch object that is selected on the TreeViewX control before this object. If no previous selected Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevSelected is used.

pvtGetParent

Returns the parent Branch of this object. If the Branch object does not have a parent, the method returns an empty Branch object.

The relative argument is ignored if GetParent is used.

pvtGetNext

Returns the next Branch object in the TreeViewX control after this object. If no subsequent Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetNext is used.

pvtGetPrevious

Returns the previous Branch object in the TreeViewX control before this object. If no previous Branch object exists, the method returns an empty Branch object.

The relative argument is ignored if GetPrevious is used.

pvtGetChild

Returns a child Branch object of this object. If no child Branch object exists, the method returns an empty Branch object. The child object obtained depends on the value of the relative argument.

Remarks

To add an item to a Branch, use the Add Method. To remove an item from a Branch, use the Remove Method.

For a single selection TreeViewX control, both the GetNextSelected and GetPrevSelected arguments will return the selected Branch if a Branch is selected. If no Branch is selected, the Get method will return an an empty Branch object.

Visual Basic Example

This example "walks" through the list of items in a TreeViewX control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Walk (mnuWalk). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuWalk_Click()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

Do While node.IsValid
Set node = node.Get(pvtGetNext, 0)
Loop
End Sub

Visual C++ Example

This example "walks" through the list of items in a TreeViewX control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object in your project. Create a button that invokes the OnWalk method when pressed.

void MyDialog::OnWalk()
{
CBranch root(m_treeview.GetBranches());
CBranch* node

node = &root.Get(CBranch::pvtGetChild, 0);

while ( node->IsValid() )
{
node = &node->Get(CBranch::pvtGetNext, 0);
}
}

GetHandle

The GetHandle method returns the item handle (HITEM) of the TreeViewX control item associated with the Branch.

Syntax

Visual Basic

handle = object.GetHandle

Visual C++

handle = object.GetHandle ();

Delphi

handle := object.GetHandle;

The GetHandle method syntax has these parts:

Part | Description
object | A Branch object.
handle | A handle which gives you direct access to the branch item.

Remarks

The HITEM handle can be used with the hWnd Property to send messages directly to the TreeViewX control.

IsLocked

Returns a boolean value indicating whether or not the Branch object is locked.

Syntax

Visual Basic

boolean = object.IsLocked

Visual C++

boolean = object.IsLocked ();

Delphi

boolean:= object.IsLocked;

The IsLocked method syntax has these parts:

Part | Description
object | A Branch object.
boolean | A boolean expression which returns if a branch item is locked.

Settings

The settings for boolean are:

Setting | Description
True | The Branch object is locked.
False | The Branch object is not locked.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.

Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then
node.Unlock
Else
node.Lock
Endif

End Sub

Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()
{
Cbranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

if ( node.IsLocked() )
node.Unlock();
else
node.Lock();
}

IsMainBranch

Returns boolean value indicating whether or not the Branch object is the main Branch object.

Syntax

Visual Basic

boolean = object.IsMainBranch

Visual C++

boolean = object.IsMainBranch ();

Delphi

boolean:= object.IsMainBranch;

The IsMainBranch method syntax has these parts:

Part | Description
object | A Branch object.
boolean | A boolean expression which returns if a branch item is the main branch.

Settings

The settings for boolean are:

Setting | Description
True | The object is the main Branch.
False | The object is not the main Branch.

Remarks

To add an item to a Branch, use the Add Method. To remove an item from a Branch, use the remove method.

IsOpen

The IsOpen property returns a boolean value indicating whether or not the Branch object is open. Read only at run time, not available at design time.

Syntax

Visual Basic

boolean = object.IsOpen

Visual C++

boolean = object.IsOpen ();

Delphi

boolean:= object.IsOpen;

The IsOpen method syntax has these parts:

Part | Description
object | A Branch object.
boolean | A boolean expression which returns if a branch item is opened.

Settings

The settings for boolean are:

Setting | Description
True | The object is open.
False | The object is closed.

Remarks

Branch objects that are not visible are automatically closed.

Note: The IsOpen property on the main Branch is meaningless. The main Branches IsOpen property is always returns True.

IsValid

Returns boolean value indicating whether or not the Branch object is a valid Branch object.

Syntax

Visual Basic

boolean = object.IsValid

Visual C++

boolean = object.IsValid ();

Delphi

boolean:= object.IsValid;

The IsValid method syntax has these parts:

Part | Description
object | A Branch object.
boolean | A boolean expression which returns if a branch item is valid.

Settings

The settings for boolean are:

Setting | Description
True | The object is a valid Branch.
False | The object is not a valid Branch.

Remarks

Some Branch object methods will return an invalid, or empty Branch object, signifiying the end of a list or a search failure.

Visual Basic Example

This example "walks" through the list of items in a TreeViewX control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Walk (mnuWalk). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuWalk_Click()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

Do While node.IsValid
Set node = node.Get(pvtGetNext, 0)
Loop
End Sub

Visual C++ Example

This example "walks" through the list of items in a TreeViewX control. It starts with the first node and continues which each successive node until an empty Branch object is returned. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnWalk method when pressed.

void MyDialog::OnWalk()
{
CBranch root(m_treeview.GetBranches());
CBranch* node;

node = &root.Get(CBranch::pvtGetChild, 0);

while ( node->IsValid() )
{
node = &node->Get(CBranch::pvtGetNext, 0);
}
}

Lock

Locks a Branch in a TreeViewX Control.

Syntax

Visual Basic

object.Lock

Visual C++

object.Lock ();

Delphi

object.Lock;

The Lock method syntax has these parts:

Part | Description
object | A Branch object.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.

Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then
node.Unlock
Else
node.Lock
Endif

End Sub

Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()
{
Cbranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

if ( node.IsLocked() )
node.Unlock();
else
node.Lock();
}

Open

Opens the Branch object according to command argument.

Syntax

Visual Basic

object.Open command

Visual C++

object.Open (command);

Delphi

object.Open (command);

The Open method syntax has these parts:

Part | Description
object | A Branch object.
command | A constant that specifies how the Open method will operate on the Branch object.

Settings

The settings for command are:

Setting | Description
pvtEnsureVisible | Ensures that the Branch object is visible by opening all parent Branches as neccessary. Does not open the Branch object itself.
pvtNode | Same as EnsureVisible. In addition, causes the Branch object to open if it has child Branches and is currently closed.
pvtChildren | Same as Node. In addition, causes all immediate children of the Branch object to open.
pvtAllChildren | Same as Children. In addition, causes all children of the Branch object to open (including grandchildren, great grandchildren, etc).

Remarks

When a Branch is locked, it retains its display state (either open or closed).

Visual Basic Example

This example opens the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Open (mnuOpen). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuOpen_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

node.Open(Node)
End Sub

Visual C++ Example

This example opens the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnOpen method when pressed.

void MyDialog::OnOpen()
{
CBranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

node.Open(CBranch::Node);
}

Remove

Removes and deletes a Branch from a TreeViewX Control.

Syntax

Visual Basic

object.Remove

Visual C++

object.Remove ();

Delphi

object.Remove;

The Remove method syntax has these parts:

Part | Description
object | A Branch object.

Remarks

To add an item to a Branch, use the Add Method. To remove all child items from a Branch, use the Clear Method.

Visual Basic Example

This example removes the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Remove (mnuRemove). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuRemove_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)
node.Remove

End Sub

Visual C++ Example

This example removes the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. Include the Branch object in your project. Create a button that invokes the OnRemove method when pressed.

void MyDialog::OnRemove()
{
CBranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

node.Remove();
}

Select

Selects or deselects the Branch object according to command argument.

Syntax

Visual Basic

object.Select command

Visual C++

object.Select (command);

Delphi

object.Select (command);

The Select method syntax has these parts:

Part | Description
object | A Branch object.
command | A constant that specifies how the Select method will operate on the Branch object.

Settings

The settings for command are:

Setting | Description
pvtNode | Causes the Branch object to be selected.
pvtUnselect | Causes the Branch object to become unselected. Not available for single selection controls.
pvtAnchor | Causes the Branch object, and all other Branch objects between this Branch and the Caret Branch, to become selected. Same as Node for single selection controls.
pvtCaret | Causes the Branch object, and all other Branch objects between this Branch and the Anchor Branch, to become selected. Same as Node for single selection controls.

Remarks

In order to be selected, a Branch object must be visible. Therefore, all selection arguments will cause the Branch object to open before the selection is made.

Visual Basic Example

This example selects the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command Select (mnuSelect). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuSelect_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

node.Select(pvtNode)
End Sub

Visual C++ Example

This example selects the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnSelect method when pressed.

void MyDialog::OnSelect()
{
CBranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

node.Select(CBranch::pvtNode)l
}

Unlock

Unlocks a Branch in a TreeViewX Control.

Syntax

Visual Basic

object.Unlock

Visual C++

object.Unlock ();

Delphi

object.Unlock;

The Unlock method syntax has these parts:

Part | Description
object | A Branch object.

Remarks

When a Branch is locked, it retains its display state (either open or closed). Clicking on the +/- buttons or double clicking has no effect on a locked item.

Visual Basic Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a form and place a TreeViewX control on the form. Set the Name property of the control to PTreeView1. Create a menu for the form that contains the command ToggleLock (mnuToggleLock). Paste the Sub procedure into the Declarations section of the form, and press F5.

Private Sub mnuToggleLock_Click ()
Dim root As Branch
Dim node As Branch

Set root = PTreeView1.Branches
Set node = root.Get(pvtGetChild, 0)

If node.IsLocked Then
node.Unlock
Else
node.Lock
Endif

End Sub

Visual C++ Example

This example toggles the lock state of the first Branch object from the list of items in a TreeViewX control. To try this example, create a dialog and place a TreeViewX control on the dialog. Set the Name property of the control to m_treeview. . Include the Branch object in your project. Create a button that invokes the OnToggleLock method when pressed.

void MyDialog::OnToggleLock()
{
Cbranch root(m_treeview.GetBranches());
Cbranch node(root.Get(CBranch::pvtGetChild, 0));

if ( node.IsLocked() )
node.Unlock();
else
node.Lock();
}